Skip to content
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

Make v_array internals private, don't allow begin/end to be modified #2874

Merged

Conversation

jackgerrits
Copy link
Member

@jackgerrits jackgerrits commented Mar 16, 2021

Required #2873

Copy link
Collaborator

@kumpera kumpera left a comment

Choose a reason for hiding this comment

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

A few questions and an out of place review of the previous PR that introduced actual_resize.

That name is pretty bad as it's not obvious what it does. I think a better naming for those placeholders are on the form xxx_but_yyy or xxx_with_yyy so, for example, it could be resize_with_stl_behavior, which still keeps the sense of impropriety of its existence.

Finally, that PR makes VW 10 promises but didn't record it in the VW 10 project board.

@@ -30,16 +30,16 @@ void features::clear()
void features::truncate_to(const features_value_iterator& pos)
{
auto i = pos._begin - values.begin();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we make this safe? If pos didn't come from values we have UD.

Copy link
Member Author

Choose a reason for hiding this comment

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

features_value_iterator is created with a ptr, so we'd likely need to enforce in its creation. In this scope I do not think we have to information to make this safe. I think this should be handled separately

rfs.space_names.end() = rfs.space_names.begin() + lrq.orig_size[right];
}
rfs.values.actual_resize(lrq.orig_size[right]);
if (all.audit || all.hash_inv) { rfs.space_names.resize(lrq.orig_size[right]); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the dtor gone?

Copy link
Member Author

Choose a reason for hiding this comment

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

rfs.space_names is a std::vector Because the destructor is handled by std::vectors resize. I don't know how this code worked before if at all...

@@ -75,12 +75,9 @@ struct v_array<T, typename std::enable_if<std::is_trivially_copyable<T>::value>:
memmove(&_begin[idx + width], &_begin[idx], (size() - (idx + width)) * sizeof(T));
}

public:
// private:
Copy link
Collaborator

Choose a reason for hiding this comment

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

<3 but commented code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Welp it is private for real now

vowpalwabbit/v_array.h Outdated Show resolved Hide resolved
@jackgerrits jackgerrits merged commit 6437fb9 into VowpalWabbit:master Mar 19, 2021
@jackgerrits jackgerrits deleted the jagerrit/v_array_iterator_hiding branch April 15, 2021 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants