Skip to content

Commit

Permalink
perf: Performance Enhancement (#144)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
lezli01 and Laszló Szabó authored Aug 23, 2021
1 parent 4dd852d commit 8891fa9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions casbin/enforcer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace casbin {
// use model matcher by default when matcher is "".
bool Enforcer::m_enforce(const std::string& matcher, Scope scope) {
m_func_map.scope = scope;
m_func_map.func_list.clear();

if(!m_enabled)
return true;
Expand Down
4 changes: 1 addition & 3 deletions casbin/util/split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ std::vector<std::string> Split(std::string str, const std::string& del, int limi

if(limit <= 0)
limit = LARGE;

tokens.reserve((limit == LARGE) ? 100000 : limit);

tokens.reserve((limit == LARGE) ? 0 : limit);
for (int i = 1; i < limit ; i++) {
size_t pos = str.find(del);
if (pos != std::string::npos) {
Expand Down

0 comments on commit 8891fa9

Please sign in to comment.