mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Strings] Split String Optimizations (#1325)
* Switch the 2 split calls to SplitString * Nuke duplicate split in favor of SplitString #1263 * Add a test for SplitString * Optimize SplitString Benchmarking: -------------------------------------------------------------- Benchmark Time CPU Iterations -------------------------------------------------------------- bench_oldsplit 5201 ns 5201 ns 129500 bench_split 1269 ns 1269 ns 548906 This is splitting a VERY long SpecialAbilities string. This is ~75% speed up.
This commit is contained in:
committed by
GitHub
parent
00fb9bc9f9
commit
dba3010c89
@@ -30,6 +30,7 @@ public:
|
||||
TEST_ADD(StringUtilTest::EscapeStringTest);
|
||||
TEST_ADD(StringUtilTest::EscapeStringMemoryTest);
|
||||
TEST_ADD(StringUtilTest::SearchDeliminatedStringTest);
|
||||
TEST_ADD(StringUtilTest::SplitStringTest);
|
||||
}
|
||||
|
||||
~StringUtilTest() {
|
||||
@@ -108,6 +109,15 @@ public:
|
||||
TEST_ASSERT(search_deliminated_string(h, "bef") == std::string::npos);
|
||||
TEST_ASSERT(search_deliminated_string(h, "wwi") == std::string::npos);
|
||||
}
|
||||
|
||||
void SplitStringTest() {
|
||||
std::string s = "123,456,789,";
|
||||
auto v = SplitString(s, ',');
|
||||
TEST_ASSERT(v.size() == 3);
|
||||
TEST_ASSERT(v[0] == "123");
|
||||
TEST_ASSERT(v[1] == "456");
|
||||
TEST_ASSERT(v[2] == "789");
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user