[Mesa-dev] [PATCH] egl: _eglFilterArray's filter is always non-null

Emil Velikov emil.l.velikov at gmail.com
Wed Feb 15 15:36:00 UTC 2017


From: Emil Velikov <emil.velikov at collabora.com>

Drop the extra handling and assert() if things change in the future.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/egl/main/eglarray.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/src/egl/main/eglarray.c b/src/egl/main/eglarray.c
index d2f39af49a..ba6cb3e6a4 100644
--- a/src/egl/main/eglarray.c
+++ b/src/egl/main/eglarray.c
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 
+#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -157,25 +158,15 @@ _eglFilterArray(_EGLArray *array, void **data, EGLint size,
    if (!array)
       return 0;
 
-   if (filter) {
-      for (i = 0; i < array->Size; i++) {
-         if (filter(array->Elements[i], filter_data)) {
-            if (data && count < size)
-               data[count] = array->Elements[i];
-            count++;
-         }
-         if (data && count >= size)
-            break;
-      }
-   }
-   else {
-      if (data) {
-         count = (size < array->Size) ? size : array->Size;
-         memcpy(data, array->Elements, count * sizeof(array->Elements[0]));
-      }
-      else {
-         count = array->Size;
+   assert(filter);
+   for (i = 0; i < array->Size; i++) {
+      if (filter(array->Elements[i], filter_data)) {
+         if (data && count < size)
+            data[count] = array->Elements[i];
+         count++;
       }
+      if (data && count >= size)
+         break;
    }
 
    return count;
-- 
2.11.0



More information about the mesa-dev mailing list