mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-04-25 07:57:01 -05:00
Use JSON.parse for parsing teambuilder tables (#1714)
This optimizes JavaScript parsing performance. V8 developers recommend applying this optimization for objects of 10 kB or larger, see <https://v8.dev/blog/cost-of-javascript-2019#json> for more details. Teambuilder tables are 3.5 MBs which is much more than 10 kB.
This commit is contained in:
parent
934eb7be2c
commit
0005f1f79f
|
|
@ -1018,7 +1018,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
|
|||
}
|
||||
}
|
||||
|
||||
buf += 'exports.BattleTeambuilderTable = ' + JSON.stringify(BattleTeambuilderTable) + ';\n\n';
|
||||
buf += `exports.BattleTeambuilderTable = JSON.parse('${JSON.stringify(BattleTeambuilderTable).replace(/['\\]/g, "\\$&")}');\n\n`;
|
||||
|
||||
fs.writeFileSync('data/teambuilder-tables.js', buf);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user