From c49ff9ee09bb96afc483315ea7f1913879f44538 Mon Sep 17 00:00:00 2001
From: nick evans <nick@rubinick.dev>
Date: Wed, 26 Feb 2025 15:10:09 -0500
Subject: [PATCH 01/23] =?UTF-8?q?=F0=9F=90=9B=20Use=20Range#size=20vs=20Ra?=
=?UTF-8?q?nge#count=20for=20uid-set=20limit?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Prior to ruby 3.3, `Range#count` is handled by `Enumerable#count`, even
for numeric ranges. For large ranges, `Range#size` is _significantly_
faster. On my system, ruby 3.2 took 54 seconds (at 100% CPU) to run
`(1...2**32).count`.
Thanks to @xiaoge1001 for reporting this issue (#410).
.bundle/gems/net-imap-0.3.8/lib/net/imap/response_parser.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletion(-)
@@ -1382,7 +1382,7 @@ module Net
when T_NUMBER then [Integer(token.value)]
when T_ATOM
entries = uid_set__ranges(token.value)
- if (count = entries.sum(&:count)) > MAX_UID_SET_SIZE
+ if (count = entries.sum(&:size)) > MAX_UID_SET_SIZE
parse_error("uid-set is too large: %d > 10k", count)
end
entries.flat_map(&:to_a)
--
2.27.0