[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pdf-devel] [patch] Removing redundant code
From: |
Gaurav Aggarwal |
Subject: |
Re: [pdf-devel] [patch] Removing redundant code |
Date: |
Mon, 31 Aug 2009 06:08:37 -0700 (PDT) |
> Attached is the patch that removes some of the redundant code from
> src/base/pdf-alloc.c file and hence saved few CPU cycles.
> Please review the changes and let me know in case any information is needed
> from
> my side.
>
Since patch send by me is not applied till this time and no reason was
provided, I believe that it requires some explanation. Here it goes:
Patch Analysis: Mainly changes are to remove the following code of snippet
from pdf-alloc.c file:
===================================================
pdf_realloc (const void *pointer, const pdf_size_t size)
{
pointer = realloc ((void *) pointer, size);
- if (!pointer && size != 0)
- {
- pointer = NULL;
- }
return (void *) pointer;
}
======================================================
Here if pointer is NULL and size is not equal to zero, we are setting the value
of pointer to NULL but here value of pointer is already NULL as checked in one
of the if condition, so it doesn't make any sense to add further checks for the
same and putting the same value if test passes. Patch will remove the if
condition block statement to avoid the extra checks and hence to save few CPU
cycles every time library/application allocates a memory.
Similar explanation applies for the pdf_malloc() function.
Hope, this clarifies the changes and motive behind the changes. Let me know, in
case one needs further information.
--
Regards,
Gaurav Aggarwal
Love Cricket? Check out live scores, photos, video highlights and more.
Click here http://cricket.yahoo.com