mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 14:00:39 -07:00
perf: add string flattening to reduce retained memory (node only)
add a memory footprint benchmark
This commit is contained in:
committed by
Jun Yang
parent
7bae5bcb79
commit
3ad512c51c
@@ -0,0 +1,3 @@
|
||||
export function flatten (str: string) {
|
||||
return str
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* This function forces a string to be re-instantiated in memory using a flat representation instead of a graph
|
||||
* of concatenated strings. This is an optimization to reduce the memory footprint of token string fragments after
|
||||
* they are parsed.
|
||||
* This optimization targets the V8 javascript engine and only works on Node.js.
|
||||
* @param {string} str
|
||||
*/
|
||||
export function flatten (str: string) {
|
||||
return Buffer.from(str).toString()
|
||||
}
|
||||
Reference in New Issue
Block a user