Skip to content

Commit d988f9b

Browse files
red-001nerzhul
authored andcommittedFeb 18, 2017
Use the ARRLEN macro in more places and remove an unused macro. (#5260)
1 parent 3d25914 commit d988f9b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed
 

Diff for: ‎src/clientiface.h

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ namespace con {
165165
class Connection;
166166
}
167167

168-
#define CI_ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0]))
169168

170169
// Also make sure to update the ClientInterface::statenames
171170
// array when modifying these enums

Diff for: ‎src/keycode.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2424
#include "debug.h"
2525
#include "util/hex.h"
2626
#include "util/string.h"
27+
#include "util/basic_macros.h"
2728

2829
class UnknownKeycode : public BaseException
2930
{
@@ -242,11 +243,10 @@ static const struct table_key table[] = {
242243

243244
#undef N_
244245

245-
#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0]))
246246

247247
struct table_key lookup_keyname(const char *name)
248248
{
249-
for (u16 i = 0; i < ARRAYSIZE(table); i++) {
249+
for (u16 i = 0; i < ARRLEN(table); i++) {
250250
if (strcmp(table[i].Name, name) == 0)
251251
return table[i];
252252
}
@@ -256,7 +256,7 @@ struct table_key lookup_keyname(const char *name)
256256

257257
struct table_key lookup_keykey(irr::EKEY_CODE key)
258258
{
259-
for (u16 i = 0; i < ARRAYSIZE(table); i++) {
259+
for (u16 i = 0; i < ARRLEN(table); i++) {
260260
if (table[i].Key == key)
261261
return table[i];
262262
}
@@ -268,7 +268,7 @@ struct table_key lookup_keykey(irr::EKEY_CODE key)
268268

269269
struct table_key lookup_keychar(wchar_t Char)
270270
{
271-
for (u16 i = 0; i < ARRAYSIZE(table); i++) {
271+
for (u16 i = 0; i < ARRLEN(table); i++) {
272272
if (table[i].Char == Char)
273273
return table[i];
274274
}

0 commit comments

Comments
 (0)
Please sign in to comment.