Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: src/templates.js

Issue 1067903004: Simplify collections.js now that it's wrapped in an IIFE (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/templates.js
diff --git a/src/templates.js b/src/templates.js
index feb5b0645b19010c232aba0f26622eeb96c7b263..6dae189039b535b42081716c7d655437c2923651 100644
--- a/src/templates.js
+++ b/src/templates.js
@@ -4,7 +4,17 @@
"use strict";
+// Called from a desugaring in the parser.
+var GetTemplateCallSite;
+
+(function() {
+
+%CheckIsBootstrapping();
+
var callSiteCache = new $Map;
+var mapGetFn = $Map.prototype.get;
+var mapSetFn = $Map.prototype.set;
+
function SameCallSiteElements(rawStrings, other) {
var length = rawStrings.length;
@@ -21,7 +31,7 @@ function SameCallSiteElements(rawStrings, other) {
function GetCachedCallSite(siteObj, hash) {
- var obj = %_CallFunction(callSiteCache, hash, $MapGet);
+ var obj = %_CallFunction(callSiteCache, hash, mapGetFn);
if (IS_UNDEFINED(obj)) return;
@@ -33,13 +43,13 @@ function GetCachedCallSite(siteObj, hash) {
function SetCachedCallSite(siteObj, hash) {
- var obj = %_CallFunction(callSiteCache, hash, $MapGet);
+ var obj = %_CallFunction(callSiteCache, hash, mapGetFn);
var array;
if (IS_UNDEFINED(obj)) {
array = new InternalArray(1);
array[0] = siteObj;
- %_CallFunction(callSiteCache, hash, array, $MapSet);
+ %_CallFunction(callSiteCache, hash, array, mapSetFn);
} else {
obj.push(siteObj);
}
@@ -48,7 +58,7 @@ function SetCachedCallSite(siteObj, hash) {
}
-function GetTemplateCallSite(siteObj, rawStrings, hash) {
+GetTemplateCallSite = function(siteObj, rawStrings, hash) {
var cached = GetCachedCallSite(rawStrings, hash);
if (!IS_UNDEFINED(cached)) return cached;
@@ -58,3 +68,5 @@ function GetTemplateCallSite(siteObj, rawStrings, hash) {
return SetCachedCallSite(%ObjectFreeze(siteObj), hash);
}
+
+})();
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698