From eec253d225f0e3d8eb594b8dfa8fe24e2d2dcb17 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 22 Jan 2017 17:35:18 +1100 Subject: Simplify initialising and reinitialising. --- lexlib/WordList.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lexlib') diff --git a/lexlib/WordList.cxx b/lexlib/WordList.cxx index b8662916c..7741fe093 100644 --- a/lexlib/WordList.cxx +++ b/lexlib/WordList.cxx @@ -29,10 +29,7 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa int words = 0; // For rapid determination of whether a character is a separator, build // a look up table. - bool wordSeparator[256]; - for (int i=0; i<256; i++) { - wordSeparator[i] = false; - } + bool wordSeparator[256] = {}; // Initialise all to false. wordSeparator[static_cast('\r')] = true; wordSeparator[static_cast('\n')] = true; if (!onlyLineEnds) { @@ -134,8 +131,7 @@ void WordList::Set(const char *s) { #else SortWordList(words, len); #endif - for (unsigned int k = 0; k < ELEMENTS(starts); k++) - starts[k] = -1; + std::fill(starts, starts + ELEMENTS(starts), -1); for (int l = len - 1; l >= 0; l--) { unsigned char indexChar = words[l][0]; starts[indexChar] = l; -- cgit v1.2.3