mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-13 07:28:03 -05:00
24 lines
461 B
TypeScript
24 lines
461 B
TypeScript
//! test_output(0)
|
|
|
|
/// <reference path="../../../concept-code/vs.d.ts" />
|
|
|
|
export default function main() {
|
|
return measure(true) - measure(false);
|
|
}
|
|
|
|
function measure(ref: boolean) {
|
|
const x = Debug.makeCopyCounter("x");
|
|
|
|
let arr = [x, "y", "z"];
|
|
|
|
if (ref) {
|
|
// Evaluating (arr) can cause it to be stored in a temporary. If this temporary persists it
|
|
// causes the mutation below to copy.
|
|
arr[1];
|
|
}
|
|
|
|
arr[2] = "zz";
|
|
|
|
return x.count;
|
|
}
|