Переглянути джерело

2008-06-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Removed repeated call of getTopDirPath(). Instead, call it once 
and
	cache the result.
	* src/MultiDiskAdaptor.cc
	* src/MultiDiskAdaptor.h
	(mkdir, openFile, initAndOpenFile, openExistingFile)
Tatsuhiro Tsujikawa 17 роки тому
батько
коміт
0c22b9faf0
3 змінених файлів з 23 додано та 12 видалено
  1. 8 0
      ChangeLog
  2. 14 11
      src/MultiDiskAdaptor.cc
  3. 1 1
      src/MultiDiskAdaptor.h

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-06-03  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	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  <tujikawa at rednoah dot com>
 
 	Fixed compile error on debian etch.

+ 14 - 11
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();
   }
 }

+ 1 - 1
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: