From b7beffa3db7103f5b800dd2ee004fe62bb577cd8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 30 Jan 2021 10:05:34 +0200 Subject: Take advantage of small std::function optimization --- libbuild2/parser.cxx | 21 +++++++++++++-------- 1 file 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&&)> appf; + struct data + { + const optional& e; + const dir_path& sp; + function&&)> appf; + + } d {e, *sp, nullptr}; + if (unique) - appf = [a, &append] (string&& v, optional&& e) + d.appf = [a, &append] (string&& v, optional&& e) { append (move (v), move (e), a); }; else - appf = [a, &include_match] (string&& v, optional&& e) + d.appf = [a, &include_match] (string&& v, optional&& 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 (e)); + d.appf (move (m).representation (), optional (d.e)); return true; }; -- cgit v1.1