mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user