Skip to content

Commit

Permalink
Merge pull request #906 from pocke/Do_not_call__class_from__hash
Browse files Browse the repository at this point in the history
Do not call #class from #hash to imorove performance
  • Loading branch information
pocke authored Feb 21, 2022
2 parents 026d73d + 5b1251c commit 4afd14d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/rbs/ast/members.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def ==(other)
alias eql? ==

def hash
self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^ overload.hash
name.hash ^ kind.hash ^ types.hash ^ overload.hash
end

def instance?
Expand Down Expand Up @@ -94,7 +94,7 @@ def ==(other)
alias eql? ==

def hash
self.class.hash ^ name.hash ^ type.hash
name.hash ^ type.hash
end
end

Expand Down Expand Up @@ -164,7 +164,7 @@ def eql?(other)
end

def hash
self.class.hash ^ name.hash ^ args.hash
name.hash ^ args.hash
end
end

Expand Down Expand Up @@ -243,7 +243,7 @@ def ==(other)
alias eql? ==

def hash
self.class.hash ^ name.hash ^ type.hash ^ ivar_name.hash ^ kind.hash
name.hash ^ type.hash ^ ivar_name.hash ^ kind.hash
end

def update(name: self.name, type: self.type, ivar_name: self.ivar_name, kind: self.kind, annotations: self.annotations, location: self.location, comment: self.comment)
Expand Down Expand Up @@ -372,7 +372,7 @@ def ==(other)
alias eql? ==

def hash
self.class.hash ^ new_name.hash ^ old_name.hash ^ kind.hash
new_name.hash ^ old_name.hash ^ kind.hash
end

def to_json(state = _ = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/rbs/namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def ==(other)
alias eql? ==

def hash
self.class.hash ^ path.hash ^ absolute?.hash
path.hash ^ absolute?.hash
end

def split
Expand Down
2 changes: 1 addition & 1 deletion lib/rbs/type_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def ==(other)
alias eql? ==

def hash
self.class.hash ^ namespace.hash ^ name.hash
namespace.hash ^ name.hash
end

def to_s
Expand Down
2 changes: 1 addition & 1 deletion lib/rbs/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def ==(other)
alias eql? ==

def hash
self.class.hash ^ name.hash ^ args.hash
name.hash ^ args.hash
end

def free_variables(set = Set.new)
Expand Down

0 comments on commit 4afd14d

Please sign in to comment.