提交 07868201 编写于 作者: J Jonathan Corbet 提交者: Linus Torvalds

flex_array: remove unneeded index calculation

flex_array_get() calculates an index value, then drops it on the floor;
simply remove it.
Signed-off-by: NJonathan Corbet <corbet@lwn.net>
Acked-by: NDave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 a40694a3
...@@ -254,7 +254,6 @@ void *flex_array_get(struct flex_array *fa, int element_nr) ...@@ -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); int part_nr = fa_element_to_part_nr(fa, element_nr);
struct flex_array_part *part; struct flex_array_part *part;
int index;
if (element_nr >= fa->total_nr_elements) if (element_nr >= fa->total_nr_elements)
return NULL; return NULL;
...@@ -264,6 +263,5 @@ void *flex_array_get(struct flex_array *fa, int element_nr) ...@@ -264,6 +263,5 @@ void *flex_array_get(struct flex_array *fa, int element_nr)
part = (struct flex_array_part *)&fa->parts[0]; part = (struct flex_array_part *)&fa->parts[0];
else else
part = fa->parts[part_nr]; part = fa->parts[part_nr];
index = index_inside_part(fa, element_nr);
return &part->elements[index_inside_part(fa, element_nr)]; return &part->elements[index_inside_part(fa, element_nr)];
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册