From: sawadatsuyoshi@... Date: 2019-05-21T08:25:36+00:00 Subject: [ruby-core:92740] [Ruby trunk Feature#15281] Speed up Set#intersect with size check. Issue #15281 has been updated by sawa (Tsuyoshi Sawada). There is a mathematical term "ordered set", which means a different thing: an algebra in which the elements are given intrinsic order. The concept in question should be named `Tuple`. ---------------------------------------- Feature #15281: Speed up Set#intersect with size check. https://bugs.ruby-lang.org/issues/15281#change-78102 * Author: RGBD (Oleg Zubchenko) * Status: Assigned * Priority: Normal * Assignee: knu (Akinori MUSHA) * Target version: ---------------------------------------- Current implementation computes set intersection s1 & s2 in O(s2.size) time. It can be reduced to O([s1.size, s2.size].min) time. Additional speedup comes from using #each instead of #do_with_enum. See files attached for benchmarks. [Pull Request](https://github.com/ruby/ruby/pull/2003) P.S. using benchmark-ips gem ---Files-------------------------------- intersect.rb (1.91 KB) intersect_standalone.rb (671 Bytes) benchmark_results.txt (3.68 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: