Skip to content
Permalink
Browse files
optimize doc tree render
  • Loading branch information
100pah committed Mar 15, 2018
1 parent e24087b commit 81ae805bd88d600be4694deb03d89be8ed6dcaee
Show file tree
Hide file tree
Showing 5 changed files with 493 additions and 198 deletions.
@@ -144,11 +144,8 @@ define(function (require) {
].join('/'))
).done($.proxy(function (schema) {

console.profile('x1');
// Before render page
this._prepareDoc(schema);
console.profileEnd('x1');

// Render page
this._applyTpl(this.$el(), TPL_TARGET);

@@ -0,0 +1,73 @@
{
"bitwise": false,
"camelcase": true,
"curly": true,
"eqeqeq": false,
"forin": false,
"immed": true,
"latedef": false,
"newcap": true,
"noarg": false,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"regexp": false,
"undef": true,
"unused": "vars",
"strict": false,
"trailing": false,
"maxparams": 20,
"maxdepth": 6,
"maxlen": 200,

"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esversion": 3,
"module": false,
"evil": true,
"expr": true,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": true,
"laxcomma": false,
"loopfunc": false,
"multistr": false,
"onecase": false,
"proto": false,
"regexdash": false,
"scripturl": false,
"smarttabs": false,
"shadow": true,
"sub": true,
"supernew": false,
"validthis": true,

"browser": true,
"couch": false,
"devel": true,
"dojo": false,
"jquery": true,
"mootools": false,
"node": false,
"nonstandard": false,
"prototypejs": false,
"rhino": false,
"wsh": false,

"nomen": false,
"onevar": false,
"passfail": false,
"white": false,

"predef": [
"global",
"define",
"require",
"JSON"
]
}
@@ -25,6 +25,7 @@ define(function (require) {
require('./lib/htmlCleaner'),
require('./lib/codeStringify'),
require('./lib/others'),
require('./lib/liteHashMap'),
require('./ui/tooltip')
);

@@ -0,0 +1,64 @@
define(function (require) {

var base = require('./base');

/**
* @constructor
* @param {Object} obj Only apply `ownProperty`.
*/
function LiteHashMap(obj) {
var thisMap = this;

if (obj instanceof LiteHashMap) {
obj.each(function (value, key) {
thisMap.set(key, value);
});
}
else if ($.isArray(obj)) {
for (var i = 0; i < obj.length; i++) {
thisMap.set(obj[i], i);
}
}
else if (obj) {
base.objForEach(obj, function (key, value) {
thisMap.set(key, value);
});
}
}

// Add prefix to avoid conflict with Object.prototype.

LiteHashMap.prototype = {
constructor: LiteHashMap,
// Do not provide `has` method to avoid defining what is `has`.
// (We usually treat `null` and `undefined` as the same, different
// from ES6 Map).
get: function (key) {
return this.hasOwnProperty(key) ? this[key] : null;
},
set: function (key, value) {
// Comparing with invocation chaining, `return value` is more commonly
// used in this case: `var someVal = map.set('a', genVal());`
return (this[key] = value);
},
// Although util.each can be performed on this hashMap directly, user
// should not use the exposed keys, who are prefixed.
each: function (cb, context) {
context !== void 0 && (cb = $.proxy(cb, context));
for (var key in this) {
this.hasOwnProperty(key) && cb(this[key], key);
}
},
// Do not use this method if performance sensitive.
removeKey: function (key) {
delete this[key];
}
};

return {
createLiteHashMap: function (obj) {
return new LiteHashMap(obj);
}
};

});

0 comments on commit 81ae805

Please sign in to comment.