From 0c22b9faf0850115a5fd78c087612a0f4ab419f3 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 3 Jun 2008 14:30:52 +0000 Subject: [PATCH] 2008-06-03 Tatsuhiro Tsujikawa Removed repeated call of getTopDirPath(). Instead, call it once and cache the result. * src/MultiDiskAdaptor.cc * src/MultiDiskAdaptor.h (mkdir, openFile, initAndOpenFile, openExistingFile) --- ChangeLog | 8 ++++++++ src/MultiDiskAdaptor.cc | 25 ++++++++++++++----------- src/MultiDiskAdaptor.h | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 467ae73f..87fdd8ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-06-03 Tatsuhiro Tsujikawa + + Removed repeated call of getTopDirPath(). Instead, call it once and + cache the result. + * src/MultiDiskAdaptor.cc + * src/MultiDiskAdaptor.h + (mkdir, openFile, initAndOpenFile, openExistingFile) + 2008-06-01 Tatsuhiro Tsujikawa Fixed compile error on debian etch. diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index 845b6f87..b22545e0 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -133,47 +133,50 @@ std::string MultiDiskAdaptor::getTopDirPath() const return storeDir+"/"+topDir; } -void MultiDiskAdaptor::mkdir() const +void MultiDiskAdaptor::mkdir(const std::string& topDirPath) const { for(FileEntries::const_iterator itr = fileEntries.begin(); itr != fileEntries.end(); itr++) { - (*itr)->setupDir(getTopDirPath()); + (*itr)->setupDir(topDirPath); } } void MultiDiskAdaptor::openFile() { - mkdir(); + const std::string topDirPath = getTopDirPath(); + mkdir(topDirPath); resetDiskWriterEntries(); for(DiskWriterEntries::iterator itr = diskWriterEntries.begin(); - itr != diskWriterEntries.end(); itr++) { - (*itr)->openFile(getTopDirPath()); + itr != diskWriterEntries.end(); ++itr) { + (*itr)->openFile(topDirPath); } } void MultiDiskAdaptor::initAndOpenFile() { - mkdir(); + const std::string topDirPath = getTopDirPath(); + mkdir(topDirPath); resetDiskWriterEntries(); for(DiskWriterEntries::iterator itr = diskWriterEntries.begin(); - itr != diskWriterEntries.end(); itr++) { - (*itr)->initAndOpenFile(getTopDirPath()); + itr != diskWriterEntries.end(); ++itr) { + (*itr)->initAndOpenFile(topDirPath); } } void MultiDiskAdaptor::openExistingFile() { + const std::string topDirPath = getTopDirPath(); resetDiskWriterEntries(); for(DiskWriterEntries::iterator itr = diskWriterEntries.begin(); - itr != diskWriterEntries.end(); itr++) { - (*itr)->openExistingFile(getTopDirPath()); + itr != diskWriterEntries.end(); ++itr) { + (*itr)->openExistingFile(topDirPath); } } void MultiDiskAdaptor::closeFile() { for(DiskWriterEntries::iterator itr = diskWriterEntries.begin(); - itr != diskWriterEntries.end(); itr++) { + itr != diskWriterEntries.end(); ++itr) { (*itr)->closeFile(); } } diff --git a/src/MultiDiskAdaptor.h b/src/MultiDiskAdaptor.h index d3131b75..69780d77 100644 --- a/src/MultiDiskAdaptor.h +++ b/src/MultiDiskAdaptor.h @@ -90,7 +90,7 @@ private: void resetDiskWriterEntries(); - void mkdir() const; + void mkdir(const std::string& topDirPath) const; std::string getTopDirPath() const; public: