OSDN Git Service

重複するコードをまとめて関数化。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sat, 2 Oct 2010 06:00:57 +0000 (06:00 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sat, 2 Oct 2010 06:00:57 +0000 (06:00 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@372 9df91469-1e22-0410-86e7-ea8537beb833

src/lychee/cls_config.cpp
src/lychee/cls_config.h

index 6a8d062..d06e3a1 100644 (file)
@@ -73,19 +73,9 @@ myConfig::~myConfig()
 {\r
        if (this->bWriteHistory)\r
        {\r
-               size_t nMax = this->ReadId(CONF_HISTORY_COUNT, 7l);\r
-               for (size_t i = 0; i < nMax && i < this->GetHistoryCount(CONF_HISTORY_PATH); i++)\r
-               {\r
-                       this->myWriteHistory(CONF_HISTORY_PATH, i);\r
-               }\r
-               for (size_t i = 0; i < nMax && i < this->GetHistoryCount(CONF_HISTORY_NAME); i++)\r
-               {\r
-                       this->myWriteHistory(CONF_HISTORY_NAME, i);\r
-               }\r
-               for (size_t i = 0; i < nMax && i < this->GetHistoryCount(CONF_HISTORY_FULL); i++)\r
-               {\r
-                       this->myWriteHistory(CONF_HISTORY_FULL, i);\r
-               }\r
+               this->myWriteHistoryLoop(CONF_HISTORY_PATH);\r
+               this->myWriteHistoryLoop(CONF_HISTORY_NAME);\r
+               this->myWriteHistoryLoop(CONF_HISTORY_FULL);\r
        }\r
 }\r
 \r
@@ -144,6 +134,14 @@ void myConfig::myWriteHistory(myConfigId confId, size_t i)
        this->Write(wxString::Format(this->label[confId], i), this->asHistory[confId - CONF_HISTORY_PATH][i]);\r
 }\r
 \r
+void myConfig::myWriteHistoryLoop(myConfigId confId)\r
+{\r
+       for (size_t i = 0; i < (size_t) this->ReadId(CONF_HISTORY_COUNT, 7l) && i < this->GetHistoryCount(confId); i++)\r
+       {\r
+               this->myWriteHistory(confId, i);\r
+       }\r
+}\r
+\r
 size_t myConfig::GetHistoryCount(myConfigId confId)\r
 {\r
        return this->asHistory[confId - CONF_HISTORY_PATH].GetCount();\r
index fe384c7..b1cdc53 100644 (file)
@@ -87,6 +87,7 @@ private:
 \r
        void myReadHistory(myConfigId confId, size_t i);\r
        void myWriteHistory(myConfigId confId, size_t i);\r
+       void myConfig::myWriteHistoryLoop(myConfigId confId);\r
 };\r
 \r
 #endif\r