-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve InternalModel (2x - 3x) allocation cost.
- Loading branch information
1 parent
1f866da
commit ca9393f
Showing
2 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This exists because `Object.create(null)` is absurdly slow compared | ||
// to `new EmptyObject()`. In either case, you want a null prototype | ||
// when you're treating the object instances as arbitrary dictionaries | ||
// and don't want your keys colliding with build-in methods on the | ||
// default object prototype. | ||
var proto = Object.create(null, { | ||
// without this, we will always still end up with (new | ||
// EmptyObject()).constructor === Object | ||
constructor: { | ||
value: undefined, | ||
enumerable: false, | ||
writable: true | ||
} | ||
}); | ||
|
||
export default function EmptyObject() {} | ||
EmptyObject.prototype = proto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters