diff options
author | George Hazan <george.hazan@gmail.com> | 2023-08-08 13:51:05 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-08-08 13:51:05 +0300 |
commit | 2b1e9515d93d024494c73d2e09481bb4b0f38c44 (patch) | |
tree | 9c021bb983ed178697d2429830a0b5389b41dccb /plugins | |
parent | f078945343dd99ff5bb83836bc87d77f1a85d32d (diff) |
fixes #3624 (NewStory: падение при поиске в Windows 7)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 12 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 56 |
2 files changed, 22 insertions, 46 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 3df1c55fda..bd12438503 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -5,7 +5,7 @@ extern HANDLE htuLog; ///////////////////////////////////////////////////////////////////////////////////////// // Filters -bool Filter::check(ItemData *item) +bool Filter::check(ItemData *item) const { if (!item) return false; if (!(flags & EVENTONLY)) { @@ -431,6 +431,16 @@ int HistoryArray::getCount() const return (nPages == 0) ? 0 : (nPages - 1) * HIST_BLOCK_SIZE + iLastPageCounter; } +int HistoryArray::find(int id, int dir, const Filter &filter) +{ + int count = getCount(); + for (int i = id + dir; i >= 0 && i < count; i += dir) + if (filter.check(get(i))) + return i; + + return -1; +} + void HistoryArray::remove(int id) { int pageNo = id / HIST_BLOCK_SIZE; diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index f274c5181a..8f24cd49dc 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -45,8 +45,7 @@ struct ItemData class Filter { uint16_t flags; - int *refCount; - wchar_t *text; + ptrW text; public: enum @@ -61,36 +60,13 @@ public: EVENTONLY = 0x100, }; - Filter(uint16_t aFlags, wchar_t *wText) + __forceinline Filter(uint16_t aFlags, wchar_t *wText) : + flags(aFlags), + text(mir_wstrdup(wText)) { - refCount = new int(0); - flags = aFlags; - text = new wchar_t[mir_wstrlen(wText) + 1]; - mir_wstrcpy(text, wText); } - Filter(const Filter &other) - { - flags = other.flags; - refCount = other.refCount; - text = other.text; - ++ *refCount; - } - Filter &operator=(const Filter &other) - { - flags = other.flags; - refCount = other.refCount; - text = other.text; - ++ *refCount; - } - ~Filter() - { - if (!-- * refCount) { - delete refCount; - delete[] text; - } - } - - bool check(ItemData *item); + + bool check(ItemData *item) const; }; enum @@ -147,29 +123,19 @@ public: void addResults(OBJLIST<SearchResult> *pArray); void clear(); int find(MEVENT hEvent); + int find(int id, int dir, const Filter &filter); int getCount() const; + void remove(int idx); void reset() { clear(); pages.insert(new ItemBlock()); } - // bool preloadEvents(int count = 10); - ItemData* get(int id, bool bLoad = false); - - void remove(int idx); - - int FindRel(int id, int dir, Filter filter) - { - int count = getCount(); - for (int i = id + dir; (i >= 0) && (i < count); i += dir) - if (filter.check(get(i))) - return i; - return -1; - } - int FindNext(int id, Filter filter) { return FindRel(id, +1, filter); } - int FindPrev(int id, Filter filter) { return FindRel(id, -1, filter); } + + __forceinline int FindNext(int id, const Filter &filter) { return find(id, +1, filter); } + __forceinline int FindPrev(int id, const Filter &filter) { return find(id, -1, filter); } }; #endif // __history_array__ |