[project @ 2005-06-30 02:51:27 by unknown_lamer]
authorunknown_lamer <unknown>
Thu, 30 Jun 2005 02:51:27 +0000 (02:51 +0000)
committerunknown_lamer <unknown>
Thu, 30 Jun 2005 02:51:27 +0000 (02:51 +0000)
Tiny speedup in Socket code.

13 files changed:
ChangeLog
bobot++.texinfo
source/Channel.C
source/Channel.H
source/ChannelList.H
source/Parser.C
source/Person.C
source/Person.H
source/Socket.C
source/User.C
source/UserCommands.C
source/UserList.C
source/UserList.H

index 8bce87d..758dd8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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
 
index 50f9ffb..cef1828 100644 (file)
@@ -42,10 +42,10 @@ Texts.
 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
index 16f8b21..1ab7b95 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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"
index 1007131..89856b5 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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
index f8da154..c4e9b35 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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
index 7c7a1a4..c950955 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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"
index 432d669..a28523e 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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"
index 6b752f9..29e23e9 100644 (file)
@@ -13,7 +13,8 @@
 
 // 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
index aa85976..1e8b89b 100644 (file)
@@ -1,5 +1,5 @@
 // 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
@@ -14,7 +14,8 @@
 
 // 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"
@@ -292,14 +293,15 @@ Socket::readLine()
     } 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
index 0347bb6..50078a5 100644 (file)
@@ -13,7 +13,8 @@
 
 // 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"
index 199e9ef..527f37e 100644 (file)
@@ -582,16 +582,24 @@ UserCommands::Help(ServerConnection *cnx, Person *from,
     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"
index 471dc83..b1038d0 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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>
index 3012664..ebeedd5 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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