Mesa (master): mesa: use util_hash_crc32 instead of _mesa_str_checksum

Marek Olšák mareko at kemper.freedesktop.org
Tue Nov 22 17:20:44 UTC 2016


Module: Mesa
Branch: master
Commit: 6dfdf52b6af416fccf28420d64585d809d745b0a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6dfdf52b6af416fccf28420d64585d809d745b0a

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Nov 18 19:23:55 2016 +0100

mesa: use util_hash_crc32 instead of _mesa_str_checksum

Reviewed-by: Timothy Arceri <timothy.arceri at collabora.com>

---

 src/mesa/main/imports.c   | 22 ----------------------
 src/mesa/main/imports.h   |  3 ---
 src/mesa/main/shaderapi.c |  3 ++-
 3 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 808b8f6..de4dd0e 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -252,28 +252,6 @@ _mesa_bitcount_64(uint64_t n)
 /*@}*/
 
 
-/**********************************************************************/
-/** \name String */
-/*@{*/
-
-
-/** Compute simple checksum/hash for a string */
-unsigned int
-_mesa_str_checksum(const char *str)
-{
-   /* This could probably be much better */
-   unsigned int sum, i;
-   const char *c;
-   sum = i = 1;
-   for (c = str; *c; c++, i++)
-      sum += *c * (i % 100);
-   return sum + i;
-}
-
-
-/*@}*/
-
-
 /** Needed due to #ifdef's, above. */
 int
 _mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list args)
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 21bcb10..ef7c378 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -346,9 +346,6 @@ _mesa_half_is_negative(GLhalfARB h)
    return h & 0x8000;
 }
 
-extern unsigned int
-_mesa_str_checksum(const char *str);
-
 extern int
 _mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4);
 
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index ab15300..9592857 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -59,6 +59,7 @@
 #include "util/ralloc.h"
 #include "util/hash_table.h"
 #include "util/mesa-sha1.h"
+#include "util/crc32.h"
 
 /**
  * Return mask of GLSL_x flags by examining the MESA_GLSL env var.
@@ -992,7 +993,7 @@ shader_source(struct gl_shader *sh, const GLchar *source)
    free((void *)sh->Source);
    sh->Source = source;
 #ifdef DEBUG
-   sh->SourceChecksum = _mesa_str_checksum(sh->Source);
+   sh->SourceChecksum = util_hash_crc32(sh->Source, strlen(sh->Source));
 #endif
 }
 




More information about the mesa-commit mailing list