codegen performance: use trim-right instead of lodash/trimEnd (#5255)

This commit is contained in:
jwbay 2017-02-09 16:04:43 -05:00 committed by Logan Smyth
parent fb0a91b750
commit 1a325ce5d5
2 changed files with 6 additions and 3 deletions

View File

@ -17,7 +17,8 @@
"detect-indent": "^4.0.0", "detect-indent": "^4.0.0",
"jsesc": "^1.3.0", "jsesc": "^1.3.0",
"lodash": "^4.2.0", "lodash": "^4.2.0",
"source-map": "^0.5.0" "source-map": "^0.5.0",
"trim-right": "^1.0.1"
}, },
"devDependencies": { "devDependencies": {
"babel-helper-fixtures": "^6.22.0", "babel-helper-fixtures": "^6.22.0",

View File

@ -1,5 +1,5 @@
import type SourceMap from "./source-map"; import type SourceMap from "./source-map";
import trimEnd from "lodash/trimEnd"; import trimRight from "trim-right";
const SPACES_RE = /^[ \t]+$/; const SPACES_RE = /^[ \t]+$/;
@ -40,7 +40,9 @@ export default class Buffer {
const map = this._map; const map = this._map;
const result = { const result = {
code: trimEnd(this._buf.join("")), // Whatever trim is used here should not execute a regex against the
// source string since it may be arbitrarily large after all transformations
code: trimRight(this._buf.join("")),
map: null, map: null,
rawMappings: map && map.getRawMappings(), rawMappings: map && map.getRawMappings(),
}; };