From 760523a45a348c26c87eb59657204f0e3cd90b26 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sat, 6 Jul 2024 06:49:39 -0400 Subject: Add find_intern to v2script Parser --- include/openvic-dataloader/detail/SymbolIntern.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/openvic-dataloader/detail') diff --git a/include/openvic-dataloader/detail/SymbolIntern.hpp b/include/openvic-dataloader/detail/SymbolIntern.hpp index d72a0ba..56576c5 100644 --- a/include/openvic-dataloader/detail/SymbolIntern.hpp +++ b/include/openvic-dataloader/detail/SymbolIntern.hpp @@ -173,6 +173,19 @@ namespace ovdl { return success; } + symbol find_intern(const CharT* str, std::size_t length) { + auto entry = _map.lookup_entry(typename traits::string_view { str, length }, traits { &_buffer }); + if (entry) + return symbol(_buffer.c_str(entry.get())); + + return symbol(); + } + template + symbol find_intern(const CharT (&literal)[N]) { + DRYAD_PRECONDITION(literal[N - 1] == CharT(0)); + return find_intern(literal, N - 1); + } + symbol intern(const CharT* str, std::size_t length) { if (_map.should_rehash()) _map.rehash(_resource, traits { &_buffer }); -- cgit v1.2.3-56-ga3b1