Explorar el Código

Avoid temporary strings in SubstVar.

Microoptimization, but still gives a measurable 2-3% improvement
when using commands with lots of output like `apt list`.
Adrian Wielgosik hace 10 años
padre
commit
732510fef9
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      apt-pkg/contrib/strutl.cc

+ 3 - 1
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)
 {