From 34beee9850ae8fe94d478c13a0716d441dddd523 Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Thu, 11 Jun 2015 22:58:58 +0300 Subject: [PATCH] Some code improvements, many "const" added --- src/crossbasetypes.hpp | 2 +- src/crossgen.hpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/crossbasetypes.hpp b/src/crossbasetypes.hpp index 528f041..9c98f50 100644 --- a/src/crossbasetypes.hpp +++ b/src/crossbasetypes.hpp @@ -6,7 +6,7 @@ #include #include -typedef std::map DictType; +typedef std::map< wxString, wxString > DictType; typedef std::vector< std::vector > GridType; typedef std::vector< std::vector > CurGridType; // Fisrt index is a word length diff --git a/src/crossgen.hpp b/src/crossgen.hpp index 0d3b25a..a6c71c2 100644 --- a/src/crossgen.hpp +++ b/src/crossgen.hpp @@ -11,7 +11,7 @@ const wxChar CELL_CLEAR = wxT('+'); const uint32_t MAX_WORD_COUNT = 262144; // =2^18 -void readDict(wxString path, DictType &dict){ +void readDict(const wxString path, DictType &dict){ wxTextFile f; f.Open(path); for ( wxString str = f.GetFirstLine(); !f.Eof(); str = f.GetNextLine() ) { @@ -26,7 +26,7 @@ void readDict(wxString path, DictType &dict){ f.Close(); }; -void readGrid(wxString path, GridType &grid){ +void readGrid(const wxString path, GridType &grid){ wxTextFile f; f.Open(path); wxString str = f.GetFirstLine(); @@ -48,7 +48,7 @@ void readGrid(wxString path, GridType &grid){ f.Close(); } -void generateWordInfo(GridType &grid, std::vector &winfos){ +void generateWordInfo(const GridType &grid, std::vector &winfos){ wxLogDebug(wxT("Printing grid: ")); for (size_t i = 0; i < grid.size(); ++i){ wxString st; @@ -117,7 +117,7 @@ void generateWordInfo(GridType &grid, std::vector &winfos){ } template -uint32_t getWordUniq(T w_ind, T w_len){ +uint32_t getWordUniq(const T w_ind, const T w_len){ return w_ind + w_len * MAX_WORD_COUNT; } @@ -173,7 +173,7 @@ bool procCross(UsedWords used, AllWordsType &words, CurGridType grid, return false; } -void generateCross(GridType &grid, DictType &dict, std::vector &words_out){ +void generateCross(GridType &grid, const DictType &dict, std::vector &words_out){ AllWordsType words; for (DictType::iterator it = dict.begin(); it != dict.end(); ++it){ if (words.size() <= it->first.size())