[ruby-core:94316] [Ruby master Bug#16026] `Set#count` performance issues

From: samuel@...
Date: 2019-08-13 01:04:44 UTC
List: ruby-core #94316
Issue #16026 has been updated by ioquatix (Samuel Williams).


I was okay with changing my implementation to use `#size` - which is what I've done. However, I don't think there is anything wrong with optimising this use case if it doesn't add any overhead to existing use case. Because `Array` does it too, it makes me think it's not a completely stupid idea.

----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026#change-80677

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next