-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PREVIEW] deprecate last and pop, implement insert, erase, capacity #1
base: parser_string_view
Are you sure you want to change the base?
Conversation
n2_i = (int)i; | ||
memmove(&ec.indices[n2_i], &ec.indices[n2_i + 1], sizeof(unsigned char) * (ec.indices.size() - n2_i - 1)); | ||
ec.indices.decr(); | ||
ec.indices.erase(n2_i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just works? It's that easy?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see its a member function, still great!
@@ -103,7 +103,7 @@ void io_buf::buf_write(char*& pointer, size_t n) | |||
flush(); | |||
else // Array is short, so increase size. | |||
{ | |||
space.resize(2 * (space.end_array - space.begin())); | |||
space.resize(2 * space.capacity()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thankyou!
@@ -1080,7 +1080,7 @@ void allowed_actions_to_label(search_private& priv, size_t ec_cnt, const action* | |||
template <class T> | |||
void ensure_size(v_array<T>& A, size_t sz) | |||
{ | |||
if ((size_t)(A.end_array - A.begin()) < sz) | |||
if (A.capacity() < sz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
usage of
back()
andpop_back()
gives a minor performance boost overlast()
andpop()
(mostly becausepop_back()
doesn't return anything).Slight losses in performance can be see in some cases, notably
pop_back()
calling the destructor andback()
requiring a pointer dereference and not being able to RVO when copying in some cases; overall has better performance characteristics than the old interface. The old interface is maintained for compatibility.Additionally added 3 new functions from the standard interface (with some minor differences). Replaced relevant places with these function calls.