Commits

Justin Love  committed e29eae8

name shuffling on root to hide last-element calculation

  • Participants
  • Parent commits 32df6de

Comments (0)

Files changed (1)

File script/cgd/require.js

     }
   }
 
+  require.roots = [""];
+  require.root = function() {
+    return require.roots.slice(-1)[0];
+  };
+
   require.path = [];
-  require.roots = [""];
   function require(filename, type) {
     var file = require.once(require.path.concat(filename).join('/'));
     D(file);
     if (file) {
-      include(require.roots.slice(-1)[0] + file, type);
+      include(require.root() + file, type);
     }
   }
   
     require.path.pop();
   };
   
-  require.root = function(path, f) {
+  require.rooted = function(path, f) {
     require.roots.push(path);
     f();
     require.roots.pop();
     var path = file.split('/').slice(0,-1).join('/');
     if (fullPath) {
       var root = fullPath.slice(0, -file.length);
-      require.root(root, function() {require.under(path, f);});
+      require.rooted(root, function() {require.under(path, f);});
     } else {
       require.under(path, f);
     }