[Mesa-dev] [PATCH 2/4] mesa: use util_hash_crc32 instead of _mesa_str_checksum
Marek Olšák
maraeo at gmail.com
Tue Nov 22 01:20:33 UTC 2016
From: Marek Olšák <marek.olsak at amd.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
@@ -245,42 +245,20 @@ _mesa_bitcount_64(uint64_t n)
for (bits = 0; n > 0; n = n >> 1) {
bits += (n & 1);
}
return bits;
}
#endif
/*@}*/
-/**********************************************************************/
-/** \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)
{
return vsnprintf( str, size, fmt, args);
}
/** Wrapper around vsnprintf() */
int
_mesa_snprintf( char *str, size_t size, const char *fmt, ... )
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
@@ -339,23 +339,20 @@ extern unsigned int
_mesa_bitcount_64(uint64_t n);
#endif
static inline bool
_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);
extern int
_mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list arg);
#if defined(_MSC_VER) && !defined(snprintf)
#define snprintf _snprintf
#endif
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
@@ -52,20 +52,21 @@
#include "compiler/glsl/glsl_parser_extras.h"
#include "compiler/glsl/ir.h"
#include "compiler/glsl/ir_uniform.h"
#include "compiler/glsl/program.h"
#include "program/program.h"
#include "program/prog_print.h"
#include "program/prog_parameter.h"
#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.
*/
GLbitfield
_mesa_get_shader_flags(void)
{
GLbitfield flags = 0x0;
const char *env = getenv("MESA_GLSL");
@@ -985,21 +986,21 @@ get_shader_source(struct gl_context *ctx, GLuint shader, GLsizei maxLength,
*/
static void
shader_source(struct gl_shader *sh, const GLchar *source)
{
assert(sh);
/* free old shader source string and install new one */
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
}
/**
* Compile a shader.
*/
void
_mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh)
{
--
2.7.4
More information about the mesa-dev
mailing list