Chromium Code Reviews| Index: src/messages.js |
| diff --git a/src/messages.js b/src/messages.js |
| index 4da38051f9200746250867e23f9cc4228c524178..a947bbfbe05aab380e6a78ca5b264d07f380ce63 100644 |
| --- a/src/messages.js |
| +++ b/src/messages.js |
| @@ -766,18 +766,18 @@ function DefineOneShotAccessor(obj, name, fun) { |
| // Note that the accessors consistently operate on 'obj', not 'this'. |
| // Since the object may occur in someone else's prototype chain we |
| // can't rely on 'this' being the same as 'obj'. |
| - var hasBeenSet = false; |
| var value; |
| + var getter_function = fun; |
|
Vyacheslav Egorov (Google)
2012/08/28 16:43:43
Is there any reason why you can't simply use fun w
|
| var getter = function() { |
| - if (hasBeenSet) { |
| + if (getter_function == null) { |
| return value; |
| } |
| - hasBeenSet = true; |
| - value = fun(obj); |
| + value = getter_function(obj); |
| + getter_function = null; |
| return value; |
| }; |
| var setter = function(v) { |
| - hasBeenSet = true; |
| + getter_function = null; |
| value = v; |
| }; |
| %DefineOrRedefineAccessorProperty(obj, name, getter, setter, DONT_ENUM); |