[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH 3/3] debListParser::DescriptionLanguage: huge speedup



---
 apt-pkg/deb/deblistparser.cc |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 68d544e..878cdd1 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -199,11 +199,19 @@ string debListParser::DescriptionLanguage()
    if (Section.FindS("Description").empty() == false)
       return "";
 
+   const char *start;
+   const char *end;
    std::vector<string> const lang = APT::Configuration::getLanguages(true);
    for (std::vector<string>::const_iterator l = lang.begin();
 	l != lang.end(); ++l)
-      if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false)
-	 return *l;
+   {
+      string element = *l;
+      char search_string[12+element.size()+1];
+      memcpy(search_string, "Description-", 12);
+      memcpy(search_string+12, element.c_str(), element.size()+1);
+      if (Section.Find(search_string, start, end) == true && start != end)
+	 return element;
+   }
 
    return "";
 }
-- 
1.7.10.4


Reply to: