From: Adrian Wielgosik Date: Tue, 2 Feb 2016 22:15:25 +0000 (+0100) Subject: Avoid temporary strings in SubstVar. X-Git-Tag: 1.2.2~6^2 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/732510fef9af5addc5e3ff1a79ce8c9658711fb6?hp=-c Avoid temporary strings in SubstVar. Microoptimization, but still gives a measurable 2-3% improvement when using commands with lots of output like `apt list`. --- 732510fef9af5addc5e3ff1a79ce8c9658711fb6 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) {