From 6b008c3eae71604b541ce81d34d0d24259f3da5a Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 11 Aug 2019 13:41:04 -0700 Subject: [PATCH] Stop caching the lowercase string contents in history items --- src/history.cpp | 5 ++++- src/history.h | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/history.cpp b/src/history.cpp index 7afc5bbae..c82a71375 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -208,13 +208,16 @@ bool history_item_t::merge(const history_item_t &item) { history_item_t::history_item_t(const wcstring &str, time_t when, history_identifier_t ident) : creation_timestamp(when), identifier(ident) { contents = trim(str); - contents_lower = wcstolower(contents); } bool history_item_t::matches_search(const wcstring &term, enum history_search_type_t type, bool case_sensitive) const { // Note that 'term' has already been lowercased when constructing the // search object if we're doing a case insensitive search. + wcstring contents_lower; + if (!case_sensitive) { + contents_lower = wcstolower(contents); + } const wcstring &content_to_match = case_sensitive ? contents : contents_lower; switch (type) { diff --git a/src/history.h b/src/history.h index 48d823efb..b9c5039bb 100644 --- a/src/history.h +++ b/src/history.h @@ -69,8 +69,7 @@ class history_item_t { bool merge(const history_item_t &item); // The actual contents of the entry. - wcstring contents; // value as entered by the user - wcstring contents_lower; // value normalized to all lowercase for case insensitive comparisons + wcstring contents; // Original creation time for the entry. time_t creation_timestamp; @@ -85,7 +84,6 @@ class history_item_t { explicit history_item_t(const wcstring &str, time_t when = 0, history_identifier_t ident = 0); const wcstring &str() const { return contents; } - const wcstring &str_lower() const { return contents_lower; } bool empty() const { return contents.empty(); }