From 04a035c19da3af4ab4ef7ce0b595695c88d105fa Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Thu, 2 Apr 2026 08:45:15 -0700 Subject: [PATCH] Improve sizeCompare doc --- library/src/scala/collection/Iterable.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/src/scala/collection/Iterable.scala b/library/src/scala/collection/Iterable.scala index fc086b114e1d..61395463e7fa 100644 --- a/library/src/scala/collection/Iterable.scala +++ b/library/src/scala/collection/Iterable.scala @@ -264,9 +264,12 @@ transparent trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] w * x > 0 if this.size > otherSize * ``` * - * The method as implemented here does not call `size` directly; its running time - * is `O(size min otherSize)` instead of `O(size)`. The method should be overridden - * if computing `size` is cheap and `knownSize` returns `-1`. + * The default implementation does not call `size`, which may be arbitrarily expensive. + * It will use `knownSize` if nonnegative. + * Otherwise, it will iterate to compute an element count, + * with complexity `O(size min otherSize)`. + * This method should be overridden if computing `size` is cheap and `knownSize` returns `-1`. + * In that case, the custom implementation should just compare `size` and `otherSize` directly. * * @see [[sizeIs]] */