[Pkg-javascript-commits] [dojo] 68/149: Cache results of _getGregorianBundle(), fixes #18629

David Prévot taffit at moszumanska.debian.org
Sat Feb 27 03:13:48 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository dojo.

commit 30bb2f5f78d93fe479c9a94267150094b9cf483e
Author: Bill Keese <bill at dojotoolkit.org>
Date:   Sun Jul 12 06:42:55 2015 -0700

    Cache results of _getGregorianBundle(), fixes #18629
---
 date/locale.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/date/locale.js b/date/locale.js
index f1f31ea..7aa88fb 100644
--- a/date/locale.js
+++ b/date/locale.js
@@ -602,6 +602,7 @@ function _buildDateTimeRE(tokens, bundle, options, pattern){
 }
 
 var _customFormats = [];
+var _cachedGregorianBundles = {};
 exports.addCustomFormats = function(/*String*/ packageName, /*String*/ bundleName){
 	// summary:
 	//		Add a reference to a bundle containing localized custom formats to be
@@ -615,15 +616,19 @@ exports.addCustomFormats = function(/*String*/ packageName, /*String*/ bundleNam
 	//		The resources must be loaded by dojo.requireLocalization() prior to use
 
 	_customFormats.push({pkg:packageName,name:bundleName});
+	_cachedGregorianBundles = {};
 };
 
 exports._getGregorianBundle = function(/*String*/ locale){
+	if(_cachedGregorianBundles[locale]){
+		return _cachedGregorianBundles[locale];
+	}
 	var gregorian = {};
 	array.forEach(_customFormats, function(desc){
 		var bundle = i18n.getLocalization(desc.pkg, desc.name, locale);
 		gregorian = lang.mixin(gregorian, bundle);
 	}, this);
-	return gregorian; /*Object*/
+	return _cachedGregorianBundles[locale] = gregorian; /*Object*/
 };
 
 exports.addCustomFormats(module.id.replace(/\/date\/locale$/, ".cldr"),"gregorian");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list