From 732510fef9af5addc5e3ff1a79ce8c9658711fb6 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Tue, 2 Feb 2016 23:15:25 +0100 Subject: Avoid temporary strings in SubstVar. Microoptimization, but still gives a measurable 2-3% improvement when using commands with lots of output like `apt list`. --- apt-pkg/contrib/strutl.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 5e641a02b..242a78449 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -464,7 +464,9 @@ string SubstVar(const string &Str,const string &Subst,const string &Contents) if (OldPos >= Str.length()) return Temp; - return Temp + string(Str,OldPos); + + Temp.append(Str, OldPos, string::npos); + return Temp; } string SubstVar(string Str,const struct SubstVar *Vars) { -- cgit v1.2.3