maskit commented on code in PR #13338:
URL: https://github.com/apache/trafficserver/pull/13338#discussion_r3478941637
##########
plugins/experimental/jax_fingerprint/context_map.h:
##########
@@ -88,10 +109,16 @@ class ContextMap
void
remove(std::string_view method_name)
{
- auto it = find_context(method_name);
- if (it != m_contexts.end()) {
- delete it->second;
- m_contexts.erase(it);
+ for (std::uint8_t i = 0; i < _size; ++i) {
Review Comment:
Fixed
##########
plugins/experimental/jax_fingerprint/context_map.h:
##########
@@ -102,42 +129,10 @@ class ContextMap
bool
empty() const
{
- return m_contexts.empty();
+ return _size == 0;
}
private:
- using ContextStorage = std::unordered_map<std::string, JAxContext *,
StringHash, std::equal_to<>>;
-
- /** Find context by method name with C++20 generic lookup fallback.
- *
- * C++20 generic unordered lookup allows finding with std::string_view in a
- * std::unordered_map<std::string, ...> without creating a temporary string.
- * For standard libraries without this feature, we fall back to constructing
- * a std::string for the lookup.
- *
- * @param[in] method_name The method name to look up.
- * @return Iterator to the found element, or end() if not found.
- */
- ContextStorage::iterator
- find_context(std::string_view method_name)
- {
-#ifdef __cpp_lib_generic_unordered_lookup
- return m_contexts.find(method_name);
-#else
- return m_contexts.find(std::string{method_name});
-#endif
- }
-
- /** const_iterator @overload */
- ContextStorage::const_iterator
- find_context(std::string_view method_name) const
- {
-#ifdef __cpp_lib_generic_unordered_lookup
- return m_contexts.find(method_name);
-#else
- return m_contexts.find(std::string{method_name});
-#endif
- }
-
- ContextStorage m_contexts;
+ std::array<std::pair<std::string_view, JAxContext *>, MAX_METHODS> _slots{};
+ std::uint8_t _size{0};
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]