Просмотр исходного кода

common_funcs: Remove ARRAY_SIZE macro

C++17 has non-member size() which we can just call where necessary.
Lioncash 8 лет назад
Родитель
Сommit
d9e316e353
3 измененных файлов с 4 добавлено и 5 удалено
  1. 0 2
      src/common/common_funcs.h
  2. 2 1
      src/core/hle/kernel/svc.cpp
  3. 2 2
      src/video_core/renderer_opengl/gl_state.cpp

+ 0 - 2
src/common/common_funcs.h

@@ -9,8 +9,6 @@
 #endif
 #endif
 #include "common/common_types.h"
 #include "common/common_types.h"
 
 
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-
 /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor.
 /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor.
 #define CONCAT2(x, y) DO_CONCAT2(x, y)
 #define CONCAT2(x, y) DO_CONCAT2(x, y)
 #define DO_CONCAT2(x, y) x##y
 #define DO_CONCAT2(x, y) x##y

+ 2 - 1
src/core/hle/kernel/svc.cpp

@@ -4,6 +4,7 @@
 
 
 #include <algorithm>
 #include <algorithm>
 #include <cinttypes>
 #include <cinttypes>
+#include <iterator>
 
 
 #include "common/logging/log.h"
 #include "common/logging/log.h"
 #include "common/microprofile.h"
 #include "common/microprofile.h"
@@ -946,7 +947,7 @@ static const FunctionDef SVC_Table[] = {
 };
 };
 
 
 static const FunctionDef* GetSVCInfo(u32 func_num) {
 static const FunctionDef* GetSVCInfo(u32 func_num) {
-    if (func_num >= ARRAY_SIZE(SVC_Table)) {
+    if (func_num >= std::size(SVC_Table)) {
         LOG_ERROR(Kernel_SVC, "unknown svc=0x%02X", func_num);
         LOG_ERROR(Kernel_SVC, "unknown svc=0x%02X", func_num);
         return nullptr;
         return nullptr;
     }
     }

+ 2 - 2
src/video_core/renderer_opengl/gl_state.cpp

@@ -2,8 +2,8 @@
 // Licensed under GPLv2 or any later version
 // Licensed under GPLv2 or any later version
 // Refer to the license.txt file included.
 // Refer to the license.txt file included.
 
 
+#include <iterator>
 #include <glad/glad.h>
 #include <glad/glad.h>
-#include "common/common_funcs.h"
 #include "common/logging/log.h"
 #include "common/logging/log.h"
 #include "video_core/renderer_opengl/gl_state.h"
 #include "video_core/renderer_opengl/gl_state.h"
 
 
@@ -192,7 +192,7 @@ void OpenGLState::Apply() const {
     }
     }
 
 
     // Textures
     // Textures
-    for (unsigned i = 0; i < ARRAY_SIZE(texture_units); ++i) {
+    for (size_t i = 0; i < std::size(texture_units); ++i) {
         if (texture_units[i].texture_2d != cur_state.texture_units[i].texture_2d) {
         if (texture_units[i].texture_2d != cur_state.texture_units[i].texture_2d) {
             glActiveTexture(TextureUnits::MaxwellTexture(i).Enum());
             glActiveTexture(TextureUnits::MaxwellTexture(i).Enum());
             glBindTexture(GL_TEXTURE_2D, texture_units[i].texture_2d);
             glBindTexture(GL_TEXTURE_2D, texture_units[i].texture_2d);