diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-06-18 14:37:51 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-06-19 14:38:30 +0200 |
commit | b47796fe2177b30c3406e2735c2e7b9b4a892292 (patch) | |
tree | 442160799313b0c24a340daa809c1fe718da0039 /crawl-ref/source/clua.cc | |
parent | 4835408b6ab43dc3c71c0b594bb414fab33921cf (diff) | |
download | crawl-ref-b47796fe2177b30c3406e2735c2e7b9b4a892292.tar.gz crawl-ref-b47796fe2177b30c3406e2735c2e7b9b4a892292.zip |
Use ARRAYSZ() instead of sizeof division, for readability.
Also, it's not vulnerable to changes to the underlying types.
Diffstat (limited to 'crawl-ref/source/clua.cc')
-rw-r--r-- | crawl-ref/source/clua.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 997118482e..15f63005ef 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -788,8 +788,7 @@ unsigned int lua_text_pattern::lfndx = 0; bool lua_text_pattern::is_lua_pattern(const std::string &s) { - for (int i = 0, size = sizeof(pat_ops) / sizeof(*pat_ops); - i < size; ++i) + for (int i = 0, size = ARRAYSZ(pat_ops); i < size; ++i) { if (s.find(pat_ops[i].token) != std::string::npos) return (true); @@ -877,7 +876,7 @@ bool lua_text_pattern::translate() const for (std::string::size_type i = 0; i < pattern.length(); ++i) { bool match = false; - for (unsigned p = 0; p < sizeof pat_ops / sizeof *pat_ops; ++p) + for (unsigned p = 0; p < ARRAYSZ(pat_ops); ++p) { const lua_pat_op &lop = pat_ops[p]; if (pattern.find(lop.token, i) == i) |