Internals: Optimize temporary memory allocations (#6517)

This patch gets rid of over 80% of temporary dynamic memory allocations
(when a malloced node is immediately freed with no other malloc in
between). It also gets rid of over 20% of all calls to malloc.

It's worth ~3% average verilation speed up with tcmalloc, and more
without tcmalloc.
This commit is contained in:
Geza Lore
2025-10-01 15:01:30 +01:00
committed by GitHub
parent 435e1149d5
commit e9c48cd1ce
19 changed files with 218 additions and 216 deletions
-4
View File
@@ -327,10 +327,6 @@ string VString::replaceWord(const string& str, const string& from, const string&
return result;
}
bool VString::startsWith(const string& str, const string& prefix) {
return str.rfind(prefix, 0) == 0; // Faster than .find(_) == 0
}
bool VString::endsWith(const string& str, const string& suffix) {
if (str.length() < suffix.length()) return false;
return str.compare(str.length() - suffix.length(), suffix.length(), suffix) == 0;