Project

General

Profile

Actions

Bug #11127

closed

Symbol#== allocates at least one string, possibly two

Added by headius (Charles Nutter) almost 9 years ago. Updated almost 9 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
all versions
[ruby-core:69090]

Description

Symbol#== is implemented by Comparable, which uses Symbol#<=>, which coerces the symbol to a String so it can use String#<=> logic.

Most people don't know this, but it adds many hidden allocations to any Symbol-heavy code that that's doing lots of == comparisons.

I propose that Symbol should define its own == that doesn't have to do the extra work for <=>. The other Comparable methods are not important because Symbols usually compared using == or ===.

Updated by headius (Charles Nutter) almost 9 years ago

Oops, I may be mistaken...I see on trunk that Symbol does define #==. This may just be JRuby being a bit behind the times.

Updated by headius (Charles Nutter) almost 9 years ago

  • Status changed from Open to Third Party's Issue

Nevermind.

Actions

Also available in: Atom PDF

Like0
Like0Like0