perf(reader): M30 删掉无人消费的下一页预取槽(refill 渲染减半、常驻 −0.69MB)+ 回书架置顶刚读完的书
This commit is contained in:
1 parent
dc559aa1ac
commit
a9638fa59c
5 files changed
+73
-34
No files matched your search
@@ -62,6 +62,13 @@ static int cmp_recent_then_name(const void *a, const void *b)
|
||||
return strcasecmp(x->title, y->title);
|
||||
}
|
||||
|
||||
/* 最近阅读排序(扫描后 / 刚读完置顶共用同一口径)。 */
|
||||
void shelf_sort_recent(shelf_book *books, int nbooks)
|
||||
{
|
||||
if (!books || nbooks < 2) return;
|
||||
qsort(books, (size_t)nbooks, sizeof(shelf_book), cmp_recent_then_name);
|
||||
}
|
||||
|
||||
typedef struct scan_ctx {
|
||||
shelf_book *books;
|
||||
int cap;
|
||||
@@ -177,7 +184,7 @@ int shelf_scan_books(const char *root, shelf_book *books, int cap,
|
||||
scan_ctx c;
|
||||
c.books = books; c.cap = cap; c.n = 0; c.truncated = 0; c.depth_skipped = 0; c.ts_fn = ts_fn;
|
||||
scan_dir(&c, root, 0, "", "");
|
||||
qsort(books, (size_t)c.n, sizeof(shelf_book), cmp_recent_then_name);
|
||||
shelf_sort_recent(books, c.n);
|
||||
if (rep) {
|
||||
rep->nbooks = c.n;
|
||||
rep->truncated = c.truncated;
|
||||
|
||||
Reference in new issue
Block a user