diff options
author | Michal Krol <michal@vmware.com> | 2009-12-08 15:46:15 +0100 |
---|---|---|
committer | Michal Krol <michal@vmware.com> | 2009-12-08 15:46:15 +0100 |
commit | ddbd2d08b7c5b5653981db8fec58d5c3244049cd (patch) | |
tree | 0395414898dd571e021140ea95d104900ef2372b /src/gallium/auxiliary/util/u_format.c | |
parent | 714e1880d9e39a7ad5e59fd48306cb92ade65e6f (diff) |
util/format: Take advantage of sequential nature of pipe_format enum.
Make sure the format descriptor table can be indexed directly.
Diffstat (limited to 'src/gallium/auxiliary/util/u_format.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_format.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index 98ea13b60b5..e0724a1a8be 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -32,15 +32,14 @@ const struct util_format_description * util_format_description(enum pipe_format format) { - const struct util_format_description *desc = util_format_description_table; + const struct util_format_description *desc; - while(TRUE) { - if(desc->format == format) - return desc; + if (format >= PIPE_FORMAT_COUNT) { + return NULL; + } - if(desc->format == PIPE_FORMAT_NONE) - return NULL; + desc = &util_format_description_table[format]; + assert(desc->format == format); - ++desc; - }; + return desc; } |