From 7b56471188507f71ab561755e2dbe6125f1c4dd9 Mon Sep 17 00:00:00 2001 From: unknown_lamer Date: Thu, 30 Jun 2005 02:51:27 +0000 Subject: [PATCH] [project @ 2005-06-30 02:51:27 by unknown_lamer] Tiny speedup in Socket code. --- ChangeLog | 8 ++++++++ bobot++.texinfo | 4 ++-- source/Channel.C | 3 ++- source/Channel.H | 3 ++- source/ChannelList.H | 3 ++- source/Parser.C | 3 ++- source/Person.C | 3 ++- source/Person.H | 3 ++- source/Socket.C | 20 +++++++++++--------- source/User.C | 3 ++- source/UserCommands.C | 28 ++++++++++++++++++---------- source/UserList.C | 3 ++- source/UserList.H | 3 ++- 13 files changed, 57 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bce87d..758dd8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2005-06-29 Clinton Ebadi + * 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 diff --git a/bobot++.texinfo b/bobot++.texinfo index 50f9ffb..cef1828 100644 --- a/bobot++.texinfo +++ b/bobot++.texinfo @@ -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 diff --git a/source/Channel.C b/source/Channel.C index 16f8b21..1ab7b95 100644 --- a/source/Channel.C +++ b/source/Channel.C @@ -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" diff --git a/source/Channel.H b/source/Channel.H index 1007131..89856b5 100644 --- a/source/Channel.H +++ b/source/Channel.H @@ -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 diff --git a/source/ChannelList.H b/source/ChannelList.H index f8da154..c4e9b35 100644 --- a/source/ChannelList.H +++ b/source/ChannelList.H @@ -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 diff --git a/source/Parser.C b/source/Parser.C index 7c7a1a4..c950955 100644 --- a/source/Parser.C +++ b/source/Parser.C @@ -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" diff --git a/source/Person.C b/source/Person.C index 432d669..a28523e 100644 --- a/source/Person.C +++ b/source/Person.C @@ -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" diff --git a/source/Person.H b/source/Person.H index 6b752f9..29e23e9 100644 --- a/source/Person.H +++ b/source/Person.H @@ -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 diff --git a/source/Socket.C b/source/Socket.C index aa85976..1e8b89b 100644 --- a/source/Socket.C +++ b/source/Socket.C @@ -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 diff --git a/source/User.C b/source/User.C index 0347bb6..50078a5 100644 --- a/source/User.C +++ b/source/User.C @@ -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" diff --git a/source/UserCommands.C b/source/UserCommands.C index 199e9ef..527f37e 100644 --- a/source/UserCommands.C +++ b/source/UserCommands.C @@ -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 >::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 >::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 \002for" diff --git a/source/UserList.C b/source/UserList.C index 471dc83..b1038d0 100644 --- a/source/UserList.C +++ b/source/UserList.C @@ -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 #include diff --git a/source/UserList.H b/source/UserList.H index 3012664..ebeedd5 100644 --- a/source/UserList.H +++ b/source/UserList.H @@ -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 -- 2.20.1