egl: _eglFilterArray's filter is always non-null
authorEmil Velikov <emil.velikov@collabora.com>
Wed, 15 Feb 2017 15:36:00 +0000 (15:36 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 16 Feb 2017 15:27:20 +0000 (15:27 +0000)
Drop the extra handling and assert() if things change in the future.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
src/egl/main/eglarray.c

index d2f39af49a677df61e3963c724c034a66fe2b9f1..ba6cb3e6a4e7b683fc9f39475c8fd02387860e8f 100644 (file)
@@ -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;