-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: hoist variables which are not mutated or reassigned
- Loading branch information
Showing
6 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
perf: hoist variables which are not mutated or reassigned |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/svelte/tests/snapshot/samples/hoist-unmodified-var/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({}); |
19 changes: 19 additions & 0 deletions
19
packages/svelte/tests/snapshot/samples/hoist-unmodified-var/_expected/client/index.svelte.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// index.svelte (Svelte VERSION) | ||
// Note: compiler output will change before 5.0 is released! | ||
import "svelte/internal/disclose-version"; | ||
import * as $ from "svelte/internal"; | ||
|
||
const count = 0; | ||
var frag = $.template(`<p> </p>`); | ||
|
||
export default function Hoist_unmodified_var($$anchor, $$props) { | ||
$.push($$props, true); | ||
|
||
/* Init */ | ||
var p = $.open($$anchor, true, frag); | ||
var text = $.child(p); | ||
|
||
text.nodeValue = $.stringify(count); | ||
$.close($$anchor, p); | ||
$.pop(); | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/snapshot/samples/hoist-unmodified-var/_expected/server/index.svelte.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// index.svelte (Svelte VERSION) | ||
// Note: compiler output will change before 5.0 is released! | ||
import * as $ from "svelte/internal/server"; | ||
|
||
export default function Hoist_unmodified_var($$payload, $$props) { | ||
$.push(true); | ||
|
||
let count = 0; | ||
|
||
$$payload.out += `<p>${$.escape_text(count)}</p>`; | ||
$.pop(); | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/snapshot/samples/hoist-unmodified-var/index.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<svelte:options runes={true} /> | ||
|
||
<script> | ||
let count = 0; | ||
</script> | ||
|
||
<p>{count}</p> |