Release v0.6.35: reduce resident memory and compact shared dictionaries

This commit is contained in:
agrynco committed 2026-11-04 14:08:05 +02:00
1 parent 004fee4976
commit d13e9849a7
21 files changed
+469 -100

No files matched your search

+20 -3
View File
@@ -479,12 +479,14 @@ struct HistoryView
{
App *app{};
std::vector<Entry> items;
std::wstring rememberedSelection, rememberedTop;
uint64_t generation{};
std::map<std::wstring, Pixels> thumbnails;
std::map<std::wstring, std::string> richTexts;
HWND rich{};
std::set<std::wstring> pending;
bool scrolling{};
bool closed{};
};
bool selectedImage(HWND w, HistoryView *v)
{
@@ -502,6 +504,7 @@ std::wstring selected(HWND w, HistoryView *v)
}
void search(HWND w, HistoryView *v)
{
v->closed = false;
auto q = value(w, 101);
auto generation = ++v->generation;
v->pending.clear();
@@ -770,6 +773,7 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
}
case WM_TIMER:
KillTimer(w, 1);
if (v->closed) return 0;
search(w, v);
return 0;
case ResultsMessage:
@@ -778,8 +782,10 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
if (result->generation != v->generation)
return 0;
auto old = selected(w, v);
if (old.empty()) old = v->rememberedSelection;
int top=(int)SendDlgItemMessageW(w,102,LB_GETTOPINDEX,0,0);
auto topId=top>=0 && top<(int)v->items.size()?v->items[top].id:L"";
if (topId.empty()) topId = v->rememberedTop;
v->items = std::move(result->items);
SendDlgItemMessageW(w, 102, WM_SETREDRAW, FALSE, 0);
SendDlgItemMessageW(w, 102, LB_RESETCONTENT, 0, 0);
@@ -823,8 +829,10 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
v->richTexts[result->id] = std::move(result->rtf);
else
v->thumbnails[result->id] = std::move(result->pixels);
trimHistoryPreviews(v->thumbnails,visible);
trimHistoryPreviews(v->richTexts,visible);
trimHistoryPreviews(v->thumbnails,visible,32,HistoryThumbnailBudget,
[](const Pixels &p) { return p.bgra.capacity(); });
trimHistoryPreviews(v->richTexts,visible,32,HistoryRichTextBudget,
[](const std::string &s) { return s.capacity(); });
if(repaint) InvalidateRect(list,&changed,FALSE);
return 0;
}
@@ -875,14 +883,23 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
return 0;
}
case WM_CLOSE:
{
v->rememberedSelection = selected(w, v);
int top = (int)SendDlgItemMessageW(w,102,LB_GETTOPINDEX,0,0);
v->rememberedTop = top >= 0 && top < (int)v->items.size() ? v->items[top].id : L"";
KillTimer(w, 1);
v->closed = true;
++v->generation; // Discard search/preview results queued before closing.
ShowWindow(w, SW_HIDE);
SendDlgItemMessageW(w,102,LB_RESETCONTENT,0,0);
std::vector<Entry>().swap(v->items);
v->thumbnails.clear();
v->richTexts.clear();
if (v->rich)
SetWindowTextW(v->rich, L"");
v->pending.clear();
++v->generation;
return 0;
}
case WM_NCDESTROY:
disposeFont(w);
v->app->historyWindow = nullptr;