Skip to content

Commit

Permalink
chore: tweak Map/Set for better inspect output
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Jun 12, 2024
1 parent 9abb98f commit ea8e4ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
19 changes: 9 additions & 10 deletions packages/svelte/src/reactivity/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,18 @@ export class ReactiveMap extends Map {
}

clear() {
var size = super.size;
if (super.size === 0) {
return;
}
// Clear first, so we get nice console.log outputs with $inspect
super.clear();

if (size !== 0) {
var sources = this.#sources;
set(this.#size, 0);
for (var s of sources.values()) {
set(s, -1);
}
increment(this.#version);
sources.clear();
var sources = this.#sources;
set(this.#size, 0);
for (var s of sources.values()) {
set(s, -1);
}
increment(this.#version);
sources.clear();
}

#read_all() {
Expand Down
21 changes: 10 additions & 11 deletions packages/svelte/src/reactivity/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,20 @@ export class ReactiveSet extends Set {
}

clear() {
var size = super.size;
if (super.size === 0) {
return;
}
// Clear first, so we get nice console.log outputs with $inspect
super.clear();
var sources = this.#sources;

if (size !== 0) {
var sources = this.#sources;

for (var s of sources.values()) {
set(s, false);
}

sources.clear();
set(this.#size, 0);
increment(this.#version);
for (var s of sources.values()) {
set(s, false);
}

sources.clear();
set(this.#size, 0);
increment(this.#version);
}

keys() {
Expand Down

0 comments on commit ea8e4ae

Please sign in to comment.