1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Removing the utterly pointless splice in scope for the much more reasonable assignment.

This commit is contained in:
Timothy Jones 2010-10-20 19:51:53 +13:00
parent 303be86291
commit 8d6b909b93
2 changed files with 2 additions and 5 deletions

View file

@ -27,10 +27,7 @@
Scope.root = null;
Scope.prototype.setVar = function(name, type) {
if (this.positions.hasOwnProperty(name)) {
return this.variables.splice(this.positions[name], 1, {
name: name,
type: type
});
return (this.variables[this.positions[name]].type = type);
} else {
this.positions[name] = this.variables.length;
return this.variables.push({

View file

@ -29,7 +29,7 @@ exports.Scope = class Scope
# Adds a new variable or overrides an existing one.
setVar: (name, type) ->
if @positions.hasOwnProperty name
@variables.splice @positions[name], 1, {name, type}
@variables[@positions[name]].type = type
else
@positions[name] = @variables.length
@variables.push {name, type}