Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

vector: fix suboptimal sol_ptr_vector_del_element implementation v2 #2012

Closed
wants to merge 1 commit into from
Closed

Conversation

kaspersky
Copy link
Contributor

Signed-off-by: Vladimir Cernov cernov.vladimir@gmail.com

Signed-off-by: Vladimir Cernov <cernov.vladimir@gmail.com>
@kaspersky kaspersky changed the title vector: fix suboptimal sol_ptr_vector_del_element implementation vector: fix suboptimal sol_ptr_vector_del_element implementation v2 May 11, 2016
@kaspersky
Copy link
Contributor Author

#1730

I have avoided copying elements in the same place without using an if statement: by having 2 for loops (first one finds first occurence, second one removes elements).

@edersondisouza
Copy link
Contributor

+1

while (i < pv->base.len && v[i] != elem) {
i++;
offset++;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to suggest the tiniest of optimizations, feel totally free to ignore: do offset = i; after the while loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vcgomes , good observation, will do. Wonder how I didn't think of it myself.

@vcgomes
Copy link
Contributor

vcgomes commented May 11, 2016

Looking good.

@kaspersky
Copy link
Contributor Author

#2019

@kaspersky kaspersky closed this May 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants