[Mesa-dev] [PATCH v2 07/12] mesa: glGet: simplify the 'enum not found' condition
Imre Deak
imre.deak at intel.com
Tue Sep 11 15:19:53 PDT 2012
On Tue, 2012-09-11 at 09:47 -0600, Brian Paul wrote:
> On 09/10/2012 12:41 AM, Imre Deak wrote:
> > When traversing the hash table looking up an enum that is invalid we
> > eventually reach the first element in the descriptor array. By looking
> > at the type of that element, which is always TYPE_API_MASK, we know that
> > we can stop the search and return error. Since this element is always
> > the first it's enough to check for its index being 0 without looking at
> > its type.
> >
> > Later in this patchset, when we generate the hash tables during build
> > time, this will allow us to remove the TYPE_API_MASK and related flags
> > completly.
> >
> > Signed-off-by: Imre Deak<imre.deak at intel.com>
> > ---
> > src/mesa/main/get.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> > index 63fe296..48c6911 100644
> > --- a/src/mesa/main/get.c
> > +++ b/src/mesa/main/get.c
> > @@ -2012,16 +2012,18 @@ find_value(const char *func, GLenum pname, void **p, union value *v)
> > mask = Elements(table(api)) - 1;
> > hash = (pname * prime_factor);
> > while (1) {
> > - d =&values[table(api)[hash& mask]];
> > + int idx = table(api)[hash& mask];
> >
> > /* If the enum isn't valid, the hash walk ends with index 0,
> > - * which is the API mask entry at the beginning of values[]. */
> > - if (unlikely(d->type == TYPE_API_MASK)) {
> > + * pointing to the first entry of values[] which doesn't hold
> > + * any valid enum. */
> > + if (unlikely(!idx)) {
>
> Minor nit, but I think "idx != 0" would be nicer here.
Ok, will use (idx == 0).
--Imre
More information about the mesa-dev
mailing list