Make url and project getters precalculated rather than functions
Make url and project getters precalculated rather than functions

--- a/js/common.js
+++ b/js/common.js
@@ -10,13 +10,13 @@
  */
 
 define(["jquery", "modules/getproject", "modules/lang", "modules/tooltip.snapshot", "modules/tooltip.commit", "modules/tooltip.tag"],
-	function($, getProject, lang, tooltipSnapshot, tooltipCommit, tooltipTag) {
+	function($, project, lang, tooltipSnapshot, tooltipCommit, tooltipTag) {
 		$(function() {
 			lang($('div.lang_select'));
 			tooltipSnapshot($('a.snapshotTip'));
 		});
 
-		if (getProject()) {
+		if (project) {
 			tooltipCommit($('a.commitTip'));
 			tooltipTag($('a.tagTip'));
 		}

--- a/js/modules/blameasync.js
+++ b/js/modules/blameasync.js
@@ -10,7 +10,7 @@
  */
 
 define(["jquery", "modules/geturl", "modules/tooltip.commit", 'modules/resources'],
-	function($, getUrl, tooltipCommit, resources) {
+	function($, url, tooltipCommit, resources) {
 
 		var blobTable = null;
 		var blameLink = null;
@@ -29,7 +29,7 @@
 			div.css('text-align', 'center');
 
 			var img = $(document.createElement('img'));
-			img.attr('src', getUrl() + 'images/blame-loader.gif');
+			img.attr('src', url + 'images/blame-loader.gif');
 			img.attr('alt', resources.Loading);
 			img.appendTo(div);
 

--- a/js/modules/commitactivitygraph.js
+++ b/js/modules/commitactivitygraph.js
@@ -10,10 +10,7 @@
  */
 
 define(["modules/geturl", "modules/getproject", "d3"],
-	function(getUrl, getProject) {
-
-		var url = null;
-		var project = null;
+	function(url, project) {
 
 		var labelrect = null;
 		var label = null;
@@ -109,9 +106,6 @@
 
 		var init = function(graphContainer) {
 
-			url = getUrl();
-			project = getProject();
-
 			x = d3.time.scale()
 				.range([10, width-10]);
 			y = d3.scale.linear()

--- a/js/modules/getproject.js
+++ b/js/modules/getproject.js
@@ -11,9 +11,7 @@
 
 define(['module'],
 	function(module) {
-		return function() {
-			return module.config().project || null;
-		}
+		return module.config().project || null;
 	}
 );
 

--- a/js/modules/geturl.js
+++ b/js/modules/geturl.js
@@ -11,9 +11,7 @@
 
 define(['module'],
 	function(module) {
-		return function() {
-			return module.config().baseurl;
-		}
+		return module.config().baseurl;
 	}
 );
 

--- a/js/modules/languagedistgraph.js
+++ b/js/modules/languagedistgraph.js
@@ -10,10 +10,7 @@
  */
 
 define(["modules/geturl", "modules/getproject", "d3"],
-	function(getUrl, getProject) {
-
-		var url = null;
-		var project = null;
+	function(url, project) {
 
 		var width = 600;
 		var height = 600;
@@ -91,9 +88,6 @@
 			arc = d3.svg.arc().innerRadius(innerRadius).outerRadius(radius);
 			grownArc = d3.svg.arc().innerRadius(innerRadius).outerRadius(radius + growRadius);
 
-			url = getUrl();
-			project = getProject();
-
 			d3.json(url + "?p=" + project + "&a=graphdata&g=languagedist", function(data) {
 				var dataEntries = d3.entries(data);
 				var count = 0;

--- a/js/modules/tooltip.commit.js
+++ b/js/modules/tooltip.commit.js
@@ -10,10 +10,7 @@
  */
 
 define(["jquery", "modules/geturl", "modules/getproject", 'modules/resources'],
-	function($, getUrl, getProject, resources) {
-
-		var url = null;
-		var project = null;
+	function($, url, project, resources) {
 
 		function getCommitHash(element) {
 			var hash = element.attr('href').match(/h=([0-9a-fA-F]{4,40}|HEAD)/);
@@ -50,9 +47,6 @@
 		return function(elements) {
 			
 			if (elements && (elements.size() > 0)) {
-				url = getUrl();
-				project = getProject();
-
 				require(['qtip'], function() {
 					elements.each(function(){
 						var jThis = $(this);

--- a/js/modules/tooltip.tag.js
+++ b/js/modules/tooltip.tag.js
@@ -10,10 +10,7 @@
  */
 
 define(["jquery", "modules/geturl", "modules/getproject", 'modules/resources'],
-	function($, getUrl, getProject, resources) {
-
-		var url = null;
-		var project = null;
+	function($, url, project, resources) {
 
 		function getTagName(element) {
 			var tag = element.attr('href').match(/t=([^&]+)/);
@@ -50,10 +47,6 @@
 		return function(elements) {
 
 			if (elements && (elements.size() > 0)) {
-
-				url = getUrl();
-				project = getProject();
-
 				require(['qtip'], function() {
 					elements.each(function(){
 						var jThis = $(this);

--- a/js/modules/treedrilldown.js
+++ b/js/modules/treedrilldown.js
@@ -10,15 +10,13 @@
  */
 
 define(["jquery", "modules/geturl", 'modules/resources'],
-	function($, getUrl, resources) {
+	function($, url, resources) {
 
 		var collapsed = '[+]';
 		var expanded = '[–]';
 		var indent = '—';
 
 		var treeTable = null;
-
-		var url = null;
 
 		function expanderLink(href, text) {
 			var a = $(document.createElement('a'));
@@ -136,7 +134,6 @@
 
 		var init = function(treeTableElem) {
 			treeTable = treeTableElem;
-			url = getUrl();
 			createExpanders();
 			treeTable.find('a.jsTree').live('click', expanderClick);
 		};

comments