Navigation Menu

Skip to content

Commit

Permalink
Require properties once at startup for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Oct 1, 2015
1 parent b227785 commit 77aab71
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions scripts/generate_properties.js
Expand Up @@ -17,35 +17,10 @@ property_files.forEach(function (property) {
if (property.substr(-3) === '.js') {
property = path.basename(property, '.js');
dashed = camelToDashed(property);
out_file.write(' Object.defineProperty(prototype, \'' + property + '\', {\n');
out_file.write(' get: function () {\n');
out_file.write(' var definition = require(\'./properties/' + property + '\').definition;\n');
out_file.write(' Object.defineProperty(prototype, \'' + property + '\', definition);\n');
out_file.write(' return this.' + property + ';\n');
out_file.write(' },\n');
out_file.write(' set: function (v) {\n');
out_file.write(' var definition = require(\'./properties/' + property + '\').definition;\n');
out_file.write(' Object.defineProperty(prototype, \'' + property + '\', definition);\n');
out_file.write(' this.' + property + ' = v;\n');
out_file.write(' },\n');
out_file.write(' enumerable: true,\n');
out_file.write(' configurable: true\n');
out_file.write(' });\n');
out_file.write(' var '+property+' = require(\'./properties/' + property + '\').definition;\n');
out_file.write(' Object.defineProperty(prototype, \'' + property + '\', '+property+')\n');
if (property !== dashed) {
out_file.write(' Object.defineProperty(prototype, \'' + dashed + '\', {\n');
out_file.write(' get: function () {\n');
out_file.write(' var definition = require(\'./properties/' + property + '\').definition;\n');
out_file.write(' Object.defineProperty(prototype, \'' + property + '\', definition);\n');
out_file.write(' return this.' + property + ';\n');
out_file.write(' },\n');
out_file.write(' set: function (v) {\n');
out_file.write(' var definition = require(\'./properties/' + property + '\').definition;\n');
out_file.write(' Object.defineProperty(prototype, \'' + property + '\', definition);\n');
out_file.write(' this.' + property + ' = v;\n');
out_file.write(' },\n');
out_file.write(' enumerable: true,\n');
out_file.write(' configurable: true\n');
out_file.write(' });\n');
out_file.write(' Object.defineProperty(prototype, \'' + dashed + '\', '+property+')\n');
}
}
});
Expand Down

0 comments on commit 77aab71

Please sign in to comment.