From d0ab2be6ba3b505ddcbb61255b9a49f709fdfe52 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 1 Aug 2025 18:02:39 +0800 Subject: [PATCH] * [perf] Caching array count to improve performance. --- framework/base/helper.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/base/helper.class.php b/framework/base/helper.class.php index 55bb75f52b..459fbcbaa4 100644 --- a/framework/base/helper.class.php +++ b/framework/base/helper.class.php @@ -1515,8 +1515,9 @@ function compress(string|array $idList): string $idList = array_values($idList); asort($idList); + $count = count($idList); $encoded = [$idList[0]]; - for($i = 1; $i < count($idList); $i++) $encoded[] = $idList[$i] - $idList[$i-1]; + for($i = 1; $i < $count; $i++) $encoded[] = $idList[$i] - $idList[$i-1]; return gzcompress(implode(',', $encoded)); }