]> git.saurik.com Git - apt.git/commitdiff
restart debSrcRecordParsers only if needed
authorDavid Kalnischkies <david@kalnischkies.de>
Wed, 29 Jan 2014 22:24:41 +0000 (23:24 +0100)
committerDavid Kalnischkies <david@kalnischkies.de>
Wed, 29 Jan 2014 23:16:20 +0000 (00:16 +0100)
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
apt-pkg/srcrecords.cc

index 5d2a67f4f599643a18791dbae4bc59666e7c41ff..a8fb465bb1e8e564f423e3bb27ea3690971a0137 100644 (file)
@@ -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<pkgSrcRecords::File> &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();
 };
 
index 2975599574fc9a67842a9ceb4628dccc71874a23..60b62850ab0a6167713edbee19daac68340468e4 100644 (file)
@@ -70,8 +70,9 @@ bool pkgSrcRecords::Restart()
    Current = Files.begin();
    for (std::vector<Parser*>::iterator I = Files.begin();
         I != Files.end(); ++I)
-      (*I)->Restart();
-   
+      if ((*I)->Offset() != 0)
+        (*I)->Restart();
+
    return true;
 }
                                                                        /*}}}*/