Skip to content

Commit

Permalink
Array#uniq can use Array#uniq! implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Sep 22, 2013
1 parent e56cb75 commit 1b5346f
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions corelib/array.rb
Expand Up @@ -1164,21 +1164,9 @@ def transpose

def uniq
%x{
var result = [],
seen = {};
for (var i = 0, length = #{self}.length, item, hash; i < length; i++) {
item = #{self}[i];
hash = item;
if (!seen[hash]) {
seen[hash] = true;
result.push(item);
}
}
return result;
var copy = #{self}.slice();
#{`copy`.uniq!}
return copy;
}
end

Expand Down

0 comments on commit 1b5346f

Please sign in to comment.