From 472376be6818b5ea43250abcbecfcab53b4a729a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 1 Apr 2022 13:45:09 +0200 Subject: Use pkgTagSection::Key in more places in src:apt The speed critical paths were converted earlier, but the remaining could benefit a tiny bit from this as well especially as we have the facility now available and can therefore brush up the code in various places in the process as well. Also takes the time to add the hidden Exists method advertised in the headers, but previously not implemented. --- apt-pkg/indexcopy.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'apt-pkg/indexcopy.cc') diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 88c2150ff..82baba337 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -413,8 +414,8 @@ bool IndexCopy::GrabFirst(string Path,string &To,unsigned int Depth) /* */ bool PackageCopy::GetFile(string &File,unsigned long long &Size) { - File = Section->FindS("Filename"); - Size = Section->FindULL("Size"); + File = Section->Find(pkgTagSection::Key::Filename).to_string(); + Size = Section->FindULL(pkgTagSection::Key::Size); if (File.empty() || Size == 0) return _error->Error("Cannot find filename or size tag"); return true; @@ -447,18 +448,13 @@ bool SourceCopy::GetFile(string &File,unsigned long long &Size) else checksumField.append(*type); - Files = Section->FindS(checksumField.c_str()); + Files = Section->FindS(checksumField); if (Files.empty() == false) break; } if (Files.empty() == true) return false; - // Stash the / terminated directory prefix - string Base = Section->FindS("Directory"); - if (Base.empty() == false && Base[Base.length()-1] != '/') - Base += '/'; - // Read the first file triplet const char *C = Files.c_str(); string sSize; @@ -472,7 +468,8 @@ bool SourceCopy::GetFile(string &File,unsigned long long &Size) // Parse the size and append the directory Size = strtoull(sSize.c_str(), NULL, 10); - File = Base + File; + auto const Base = Section->Find(pkgTagSection::Key::Directory); + File = flCombine(Base.to_string(), File); return true; } /*}}}*/ -- cgit v1.2.3-70-g09d2