[Mesa-dev] [PATCH] mesa: simplify _mesa_IsVertexArray()
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue Jun 20 17:17:37 UTC 2017
On 06/20/2017 06:57 PM, Ian Romanick wrote:
> On 06/20/2017 06:13 AM, Samuel Pitoiset wrote:
>> _mesa_lookup_vao() already returns NULL if id is zero.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>> src/mesa/main/arrayobj.c | 7 +------
>> 1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
>> index 82c00fbe826..7988a225baf 100644
>> --- a/src/mesa/main/arrayobj.c
>> +++ b/src/mesa/main/arrayobj.c
>> @@ -605,14 +605,9 @@ _mesa_IsVertexArray( GLuint id )
>> GET_CURRENT_CONTEXT(ctx);
>> ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
>>
>> - if (id == 0)
>> - return GL_FALSE;
>> -
>> obj = _mesa_lookup_vao(ctx, id);
>> - if (obj == NULL)
>> - return GL_FALSE;
>>
>> - return obj->EverBound;
>> + return obj ? obj->EverBound : GL_FALSE;
>
> Using ?: makes the change from the original code obvious, but I think
>
> return obj != NULL && obj->EverBound;
>
> will be more clear for the future. I remember writing an optimization
> pass for the GLSL compiler that makes this same translation. :)
Yes, pushed with your suggestion. :)
>
>> }
>>
>>
>>
More information about the mesa-dev
mailing list