Skip to content

Commit

Permalink
Allow unsafe Vector iteration over underlying std::vector.
Browse files Browse the repository at this point in the history
Iterating over hilti::Vector is quite expensive due to the weak_ptr::lock()
calls. For unsafe uses, allow access to the underlying std::vector for
faster raw iteration speed.
  • Loading branch information
awelzel committed Dec 5, 2023
1 parent 817c2ed commit 76e4d65
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hilti/runtime/include/types/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ class Vector : protected std::vector<T, Allocator> {
auto cbegin() const { return const_iterator(0U, _control); }
auto cend() const { return const_iterator(size(), _control); }

auto unsafeBegin() const { return V::cbegin(); }
auto unsafeEnd() const { return V::cend(); }

size_type size() const { return V::size(); }

// Methods of `std::vector`.
Expand Down

0 comments on commit 76e4d65

Please sign in to comment.