summaryrefslogtreecommitdiffstats
path: root/src/mesa/program/prog_parameter.h
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-03-18 11:21:13 +1100
committerTimothy Arceri <[email protected]>2016-03-18 12:42:39 +1100
commitfa9bd6b663a1c78d5a17e3ad5407ff5530fbb0c9 (patch)
tree96bc0f3c4f25cc42062bac59106eb67132b85e8a /src/mesa/program/prog_parameter.h
parent350b1ef027167af12156df92f449f370a0f8d396 (diff)
mesa: simplify and inline _mesa_lookup_parameter_index()
The function has only one user and strings are always null terminated. Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa/program/prog_parameter.h')
-rw-r--r--src/mesa/program/prog_parameter.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h
index c17d703040d..b4b24a11af3 100644
--- a/src/mesa/program/prog_parameter.h
+++ b/src/mesa/program/prog_parameter.h
@@ -34,6 +34,7 @@
#include "main/mtypes.h"
#include "prog_statevars.h"
+#include <string.h>
#ifdef __cplusplus
extern "C" {
@@ -124,9 +125,23 @@ extern GLint
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
const gl_state_index stateTokens[STATE_LENGTH]);
-extern GLint
+
+static inline GLint
_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
- GLsizei nameLen, const char *name);
+ const char *name)
+{
+ if (!paramList)
+ return -1;
+
+ /* name must be null-terminated */
+ for (GLint i = 0; i < (GLint) paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Name &&
+ strcmp(paramList->Parameters[i].Name, name) == 0)
+ return i;
+ }
+
+ return -1;
+}
#ifdef __cplusplus
}