Tiny speedup in Socket code.
2005-06-29 Clinton Ebadi <clinton@unknownlamer.org>
+ * bobot++.texinfo: Updated copyright years, changed "applies to
+ 2.1.5" to 2.2
+
+ * source/Socket.C (readLine): return buf.substr (0, pos) instead
+ of using the String char * constructor (this should be faster,
+ especially for long strings since a simple copy is used instead of
+ going over each char until nul is encountered)
+
* configure.ac: Release 2.1.8
Change version to 2.1.9CVS
This document describes Bobot++ by Clinton Ebadi and Etienne Bernard
(original author, no longer works on program).
-This document applies to version 2.1.5 of the program named
+This document applies to version 2.2 of the program named
Bobot++
-Copyright 2002,2004 Clinton Ebadi
+Copyright 2002,2004,2005 Clinton Ebadi
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifdef HAVE_CONFIG_H
#include "config.h"
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifndef CHANNEL_H
#define CHANNEL_H
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifndef CHANNELLIST_H
#define CHANNELLIST_H
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifdef HAVE_CONFIG_H
#include "config.h"
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#include "Utils.H"
#include "Person.H"
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifndef PERSON_H
#define PERSON_H
// Socket.C -*- C++ -*-
-// Copyright (C) 2002 Clinton Ebadi
+// Copyright (C) 2002,2005 Clinton Ebadi
// Copyright (c) 1997, 1998 Etienne BERNARD
// This program is free software; you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#include "Socket.H"
#include "Bot.H"
} while (r != '\n');
if (pos > 1 && buf[pos-2] == '\r')
- buf[pos-2] = '\0';
+ {
+ buf[pos-2] = '\0';
+ return String (buf.substr (0, pos - 2));
+ }
else
- buf[pos-1] = '\0';
-
- // c_str () is used because the String constructor for std::string
- // will copy the entire std::string into it when we only want it to
- // copy up to the first null.
- return String (buf.c_str ());
+ {
+ buf[pos-1] = '\0';
+ return String (buf.substr (0, pos - 1));
+ }
}
String
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#include "Utils.H"
#include "User.H"
int level = Utils::get_level(cnx->bot, from->getAddress());
String result = "";
int length = 0;
- std::map<std::string, class userFunction*, std::less<std::string> >::iterator it;
- for (it = cnx->bot->userFunctions.begin(); it != cnx->bot->userFunctions.end(); ++it)
- if ((*it).second->minLevel <= level) {
- result = result + (*it).first + " ";
- length += (*it).first.length() + 1;
- if (length >= 256) {
- from->sendNotice(result);
- result = ""; length = 0;
- }
- }
+ std::map<std::string, class userFunction*,
+ std::less<std::string> >::iterator it;
+
+ for (it = cnx->bot->userFunctions.begin();
+ it != cnx->bot->userFunctions.end(); ++it)
+ {
+ if ((*it).second->minLevel <= level)
+ {
+ result = result + (*it).first + " ";
+ length += (*it).first.length() + 1;
+
+ if (length >= 256)
+ {
+ from->sendNotice(result);
+ result = ""; length = 0;
+ }
+ }
+ }
if (result != "")
from->sendNotice(result);
from->sendNotice("\002Use\002 HELP <command> \002for"
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#include <fstream>
#include <iostream>
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifndef USERLIST_H
#define USERLIST_H