From 6a9c9d63edc878ff268cdaa4f985ca50c48380b0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 29 Jan 2014 23:24:41 +0100 Subject: restart debSrcRecordParsers only if needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The offset variable in DebSrcRecordParser was not initialized which we now do and based on it do not trigger a restart if the parser was not used yet avoiding a needless rescan of the section. Detected while working on the previous commit e62aa1dd. Both commits act as a "fix" for the bug shown in the testcase of the commit – this one here would only hide it through. --- apt-pkg/deb/debsrcrecords.h | 6 +++--- apt-pkg/srcrecords.cc | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h index 5d2a67f4f..a8fb465bb 100644 --- a/apt-pkg/deb/debsrcrecords.h +++ b/apt-pkg/deb/debsrcrecords.h @@ -30,7 +30,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser public: - virtual bool Restart() {return Tags.Jump(Sect,0);}; + virtual bool Restart() {return Jump(0);}; virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);}; virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);}; @@ -50,8 +50,8 @@ class debSrcRecordParser : public pkgSrcRecords::Parser virtual bool Files(std::vector &F); debSrcRecordParser(std::string const &File,pkgIndexFile const *Index) - : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400), - Buffer(NULL) {} + : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400), + iOffset(0), Buffer(NULL) {} virtual ~debSrcRecordParser(); }; diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 297559957..60b62850a 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -70,8 +70,9 @@ bool pkgSrcRecords::Restart() Current = Files.begin(); for (std::vector::iterator I = Files.begin(); I != Files.end(); ++I) - (*I)->Restart(); - + if ((*I)->Offset() != 0) + (*I)->Restart(); + return true; } /*}}}*/ -- cgit v1.2.3