mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] flex_array: remove unneeded index calculation
@ 2009-08-04 19:35 Jonathan Corbet
  2009-08-04 21:23 ` Dave Hansen
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Corbet @ 2009-08-04 19:35 UTC (permalink / raw)
  To: Dave Hansen; +Cc: LKML, Linus Torvalds

flex_array_get() calculates an index value, then drops it on the floor;
simply remove it.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>

diff --git a/lib/flex_array.c b/lib/flex_array.c
index 0e7894c..08f1636 100644
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -254,7 +254,6 @@ void *flex_array_get(struct flex_array *fa, int element_nr)
 {
 	int part_nr = fa_element_to_part_nr(fa, element_nr);
 	struct flex_array_part *part;
-	int index;
 
 	if (element_nr >= fa->total_nr_elements)
 		return NULL;
@@ -264,6 +263,5 @@ void *flex_array_get(struct flex_array *fa, int element_nr)
 		part = (struct flex_array_part *)&fa->parts[0];
 	else
 		part = fa->parts[part_nr];
-	index = index_inside_part(fa, element_nr);
 	return &part->elements[index_inside_part(fa, element_nr)];
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] flex_array: remove unneeded index calculation
  2009-08-04 19:35 [PATCH] flex_array: remove unneeded index calculation Jonathan Corbet
@ 2009-08-04 21:23 ` Dave Hansen
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Hansen @ 2009-08-04 21:23 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: LKML, Linus Torvalds

On Tue, 2009-08-04 at 13:35 -0600, Jonathan Corbet wrote:
> flex_array_get() calculates an index value, then drops it on the floor;
> simply remove it.
> 
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>

Looks good to me.  Thanks, Jonathan.


Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>

-- Dave


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-04 21:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-04 19:35 [PATCH] flex_array: remove unneeded index calculation Jonathan Corbet
2009-08-04 21:23 ` Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®