diff options
| author | 2010-04-12 18:22:44 -0500 | |
|---|---|---|
| committer | 2010-08-03 17:32:42 -0400 | |
| commit | c120a4e37f8d13f0e2540e2534bd7cc36e1f1950 (patch) | |
| tree | a0415046bbde3c687bf87c2b48b9963bdf9861ab /src/hashcomp.cpp | |
| parent | Remove unneeded copy of server name for every remote user (diff) | |
| download | inspircd++-c120a4e37f8d13f0e2540e2534bd7cc36e1f1950.tar.gz inspircd++-c120a4e37f8d13f0e2540e2534bd7cc36e1f1950.tar.bz2 inspircd++-c120a4e37f8d13f0e2540e2534bd7cc36e1f1950.zip | |
Make irc::string faster and less wasteful
Change irc::string from an std::basic_string typedef to a wrapper around
an std::string, to avoid unneeded copies in assign().
Diffstat (limited to 'src/hashcomp.cpp')
| -rw-r--r-- | src/hashcomp.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index c88e1ef77..af07c2f12 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -148,7 +148,7 @@ void nspace::strlower(char *n) #endif { register size_t t = 0; - for (irc::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */ + for (std::string::const_iterator x = s.value.begin(); x != s.value.end(); ++x) /* ++x not x++, as its faster */ t = 5 * t + national_case_insensitive_map[(unsigned char)*x]; return t; } @@ -215,6 +215,16 @@ const char* irc::irc_char_traits::find(const char* s1, int n, char c) return (n >= 0) ? s1 : NULL; } +std::string irc::irc_char_traits::remap(const std::string& source) +{ + std::string rv; + std::string::size_type len = source.length(); + rv.reserve(len); + for(size_t i=0; i < len; i++) + rv.push_back(national_case_insensitive_map[(unsigned char)source[i]]); + return rv; +} + irc::tokenstream::tokenstream(const std::string &source) : tokens(source), last_pushed(false) { /* Record starting position and current position */ |
