From 76e4d65af703e1982510163207e2f994a204ce16 Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Tue, 5 Dec 2023 14:25:28 +0100 Subject: [PATCH] Allow unsafe Vector iteration over underlying std::vector. 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. --- hilti/runtime/include/types/vector.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hilti/runtime/include/types/vector.h b/hilti/runtime/include/types/vector.h index 0b0845d5a..95cc1d327 100644 --- a/hilti/runtime/include/types/vector.h +++ b/hilti/runtime/include/types/vector.h @@ -490,6 +490,9 @@ class Vector : protected std::vector { 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`.