Skip to content

Commit 8891fa9

Browse files
lezli01Laszló Szabó
andauthored
perf: Performance Enhancement (#144)
* perf: Clear the list of functions for every new duktape context Signed-off-by: Laszló Szabó <[email protected]> * perf: Split should only reserve vector of limit is set Signed-off-by: Laszló Szabó <[email protected]> Co-authored-by: Laszló Szabó <[email protected]>
1 parent 4dd852d commit 8891fa9

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

casbin/enforcer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace casbin {
3838
// use model matcher by default when matcher is "".
3939
bool Enforcer::m_enforce(const std::string& matcher, Scope scope) {
4040
m_func_map.scope = scope;
41+
m_func_map.func_list.clear();
4142

4243
if(!m_enabled)
4344
return true;

casbin/util/split.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ std::vector<std::string> Split(std::string str, const std::string& del, int limi
3333

3434
if(limit <= 0)
3535
limit = LARGE;
36-
37-
tokens.reserve((limit == LARGE) ? 100000 : limit);
38-
36+
tokens.reserve((limit == LARGE) ? 0 : limit);
3937
for (int i = 1; i < limit ; i++) {
4038
size_t pos = str.find(del);
4139
if (pos != std::string::npos) {

0 commit comments

Comments
 (0)