diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-01-30 10:05:34 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-01-30 10:05:34 +0200 |
commit | b7beffa3db7103f5b800dd2ee004fe62bb577cd8 (patch) | |
tree | f23dfb1504b466b3f472e7721337d945391bf039 /libbuild2 | |
parent | f211934d6ff53388a806c5cc06483e9d843056e4 (diff) |
Take advantage of small std::function optimization
Diffstat (limited to 'libbuild2')
-rw-r--r-- | libbuild2/parser.cxx | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index ab4fa48..951759b 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -4754,21 +4754,26 @@ namespace build2 // bool unique (r.empty () && path_pattern_recursive (path (p)) <= 1); - function<void (string&&, optional<string>&&)> appf; + struct data + { + const optional<string>& e; + const dir_path& sp; + function<void (string&&, optional<string>&&)> appf; + + } d {e, *sp, nullptr}; + if (unique) - appf = [a, &append] (string&& v, optional<string>&& e) + d.appf = [a, &append] (string&& v, optional<string>&& e) { append (move (v), move (e), a); }; else - appf = [a, &include_match] (string&& v, optional<string>&& e) + d.appf = [a, &include_match] (string&& v, optional<string>&& e) { include_match (move (v), move (e), a); }; - auto process = [this, &e, &appf, sp] (path&& m, - const string& p, - bool interm) + auto process = [&d, this] (path&& m, const string& p, bool interm) { // Ignore entries that start with a dot unless the pattern that // matched them also starts with a dot. Also ignore directories @@ -4780,14 +4785,14 @@ namespace build2 (root_ != nullptr && root_->root_extra != nullptr && m.to_directory () && - exists (*sp / m / root_->root_extra->buildignore_file))) + exists (d.sp / m / root_->root_extra->buildignore_file))) return !interm; // Note that we have to make copies of the extension since there will // multiple entries for each pattern. // if (!interm) - appf (move (m).representation (), optional<string> (e)); + d.appf (move (m).representation (), optional<string> (d.e)); return true; }; |