[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
237/376: Don't recompile the same regex over and over
From: |
Ludovic Courtès |
Subject: |
237/376: Don't recompile the same regex over and over |
Date: |
Wed, 28 Jan 2015 22:05:18 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 3b5fa8d50cd7e4db0691884effcbdc7809ad9ed9
Author: Eelco Dolstra <address@hidden>
Date: Fri Oct 3 21:29:20 2014 +0200
Don't recompile the same regex over and over
---
src/libexpr/names.cc | 5 ++---
src/libexpr/names.hh | 6 ++++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/libexpr/names.cc b/src/libexpr/names.cc
index c2b2733..cda5aa1 100644
--- a/src/libexpr/names.cc
+++ b/src/libexpr/names.cc
@@ -1,6 +1,5 @@
#include "names.hh"
#include "util.hh"
-#include "regex.hh"
namespace nix {
@@ -34,8 +33,8 @@ DrvName::DrvName(const string & s) : hits(0)
bool DrvName::matches(DrvName & n)
{
if (name != "*") {
- Regex regex(name);
- if (!regex.matches(n.name)) return false;
+ if (!regex) regex = std::shared_ptr<Regex>(new Regex(name));
+ if (!regex->matches(n.name)) return false;
}
if (version != "" && version != n.version) return false;
return true;
diff --git a/src/libexpr/names.hh b/src/libexpr/names.hh
index ebe113e..4b3dcdd 100644
--- a/src/libexpr/names.hh
+++ b/src/libexpr/names.hh
@@ -1,6 +1,9 @@
#pragma once
+#include <memory>
+
#include "types.hh"
+#include "regex.hh"
namespace nix {
@@ -14,6 +17,9 @@ struct DrvName
DrvName();
DrvName(const string & s);
bool matches(DrvName & n);
+
+private:
+ std::shared_ptr<Regex> regex;
};
typedef list<DrvName> DrvNames;
- 262/376: Revert "Drop support for pre-c++11 compilers.", (continued)
- 262/376: Revert "Drop support for pre-c++11 compilers.", Ludovic Courtès, 2015/01/28
- 263/376: Fix build on gcc < 4.7, Ludovic Courtès, 2015/01/28
- 244/376: Show total allocations, Ludovic Courtès, 2015/01/28
- 293/376: Remove Hydra build product, Ludovic Courtès, 2015/01/28
- 279/376: Add a launchd configuration file to run nix-daemon, Ludovic Courtès, 2015/01/28
- 251/376: nix-channel --add: Validate URL / channel ID, Ludovic Courtès, 2015/01/28
- 252/376: Remove redundant space in usage errors, Ludovic Courtès, 2015/01/28
- 290/376: realiseContext: Handle all context types, Ludovic Courtès, 2015/01/28
- 276/376: Improve error message if the daemon worker fails to start, Ludovic Courtès, 2015/01/28
- 267/376: Remove comments claiming we use a private PID namespace, Ludovic Courtès, 2015/01/28
- 237/376: Don't recompile the same regex over and over,
Ludovic Courtès <=
- 297/376: Build Ubuntu 14.10 package, Ludovic Courtès, 2015/01/28
- 268/376: Document some primops, Ludovic Courtès, 2015/01/28
- 272/376: Shut up a clang warning, Ludovic Courtès, 2015/01/28
- 257/376: Revert "binary download: Use $NIX_CURL_FLAGS", Ludovic Courtès, 2015/01/28
- 266/376: doc: fixed nix-instantiate --find-file, Ludovic Courtès, 2015/01/28
- 282/376: download-from-binary-cache.pl: Fix flushing of stderr, Ludovic Courtès, 2015/01/28
- 256/376: Merge pull request #372 from wmertens/patch-4, Ludovic Courtès, 2015/01/28
- 280/376: Typo, Ludovic Courtès, 2015/01/28
- 281/376: nix-store --gc: Don't warn about missing manifests directory, Ludovic Courtès, 2015/01/28
- 161/376: Restructuring the Nix manual, Ludovic Courtès, 2015/01/28