From 348f13df02fa560d263e857ad44bd183f100dfe7 Mon Sep 17 00:00:00 2001 From: CismonX Date: Thu, 27 Feb 2025 14:26:24 +0800 Subject: [PATCH] backend_firefox: improve length(url) performace The SQLite builtin function `length()` calculates the number of Unicode code points of the given argument, while `octet_length()` calculates the number of bytes. The two functions should produce the same result for a URL since it's always ASCII-only, however, with `octet_length()` the length can be directly fetched from metadata without actually reading the URL text, thereby improving performance. --- src/backend_firefox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend_firefox.c b/src/backend_firefox.c index 106ccae..5d03dfd 100644 --- a/src/backend_firefox.c +++ b/src/backend_firefox.c @@ -2091,7 +2091,7 @@ bookmark_do_list ( "WHERE `b`.`parent` = ? AND `b`.`position` >= ? ORDER BY `b`.`position`" #define BOOKMARK_LIST_NOJOIN_(col) BOOKMARK_LIST_(col ", `b`.`fk` ", ) #define BOOKMARK_LIST_EX_COLS_ \ - "length(`p`.`url`), `b`.`lastModified`, `p`.`last_visit_date`" + "octet_length(`p`.`url`), `b`.`lastModified`, `p`.`last_visit_date`" #define BOOKMARK_LIST_EX_(col) \ BOOKMARK_LIST_(col ", " BOOKMARK_LIST_EX_COLS_ " ", \ "LEFT JOIN `moz_places` `p` ON `b`.`fk` = `p`.`id` ") @@ -2181,7 +2181,7 @@ bookmark_do_lookup ( ) { #define BOOKMARK_LOOKUP_(join, where) \ "SELECT `b`.`id`, `b`.`lastModified`, " \ - "`p`.`last_visit_date`, length(`p`.`url`) " \ + "`p`.`last_visit_date`, octet_length(`p`.`url`) " \ "FROM `moz_bookmarks` `b` " \ join "JOIN `moz_places` `p` ON `b`.`fk` = `p`.`id` WHERE " where #define BOOKMARK_LOOKUP_ASSOC_(col) \