Skip to content

Commit e763868

Browse files
NullVoxPopuliclaude
andcommitted
Revert: drop the two zero-impact commits
Per a measurement pass, two commits had zero (or negative) effect on the hello-world prod bundle: - a0b1f09 (Move Meta mixin methods to standalone fns): bundle went from 134.17 KB → 134.19 KB (+0.02 KB). Mixin.create chain was already being tree-shaken in prod regardless. - 75761b8 (Decouple VM debug symbols/names from opcodes.ts): bundle held at 134.12 KB. LOCAL_DEBUG=false in dist/prod (and dist/dev) was already constant-folding the debug branches out, and vite was already tree-shaking the unused @glimmer/debug imports out of the smoke-test bundle. Both refactors were architecturally cleaner but pure no-ops at the bundle measurement that motivated this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent a43f2c8 commit e763868

4 files changed

Lines changed: 164 additions & 186 deletions

File tree

packages/@ember/-internals/meta/lib/meta.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,45 @@ export class Meta {
267267
return undefined;
268268
}
269269

270+
/** @internal */
271+
addMixin(mixin: any) {
272+
assert(
273+
isDestroyed(this.source)
274+
? `Cannot add mixins of \`${toString(mixin)}\` on \`${toString(
275+
this.source
276+
)}\` call addMixin after it has been destroyed.`
277+
: '',
278+
!isDestroyed(this.source)
279+
);
280+
let set = this._getOrCreateOwnSet('_mixins');
281+
set.add(mixin);
282+
}
283+
284+
/** @internal */
285+
hasMixin(mixin: any) {
286+
return this._hasInInheritedSet('_mixins', mixin);
287+
}
288+
289+
/** @internal */
290+
forEachMixins(fn: Function) {
291+
let pointer: Meta | null = this;
292+
let seen: Set<any> | undefined;
293+
while (pointer !== null) {
294+
let set = pointer._mixins;
295+
if (set !== undefined) {
296+
seen = seen === undefined ? new Set() : seen;
297+
// TODO cleanup typing here
298+
set.forEach((mixin: any) => {
299+
if (!seen!.has(mixin)) {
300+
seen!.add(mixin);
301+
fn(mixin);
302+
}
303+
});
304+
}
305+
pointer = pointer.parent;
306+
}
307+
}
308+
270309
/** @internal */
271310
writeDescriptors(subkey: string, value: any) {
272311
assert(

packages/@ember/object/mixin.ts

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,6 @@
44
import { INIT_FACTORY } from '@ember/-internals/container/lib/container';
55
import type { Meta } from '@ember/-internals/meta/lib/meta';
66
import { meta as metaFor, peekMeta } from '@ember/-internals/meta/lib/meta';
7-
import { isDestroyed } from '@glimmer/destroyable';
8-
import toString from '@ember/-internals/utils/lib/to-string';
9-
10-
function metaAddMixin(meta: Meta, mixin: any): void {
11-
assert(
12-
isDestroyed(meta.source as object)
13-
? `Cannot add mixins of \`${toString(mixin)}\` on \`${toString(
14-
meta.source
15-
)}\` call addMixin after it has been destroyed.`
16-
: '',
17-
!isDestroyed(meta.source as object)
18-
);
19-
let set = meta._mixins ?? (meta._mixins = new Set());
20-
set.add(mixin);
21-
}
22-
23-
function metaHasMixin(meta: Meta, mixin: any): boolean {
24-
let pointer: Meta | null = meta;
25-
while (pointer !== null) {
26-
let set = pointer._mixins;
27-
if (set !== undefined && set.has(mixin)) {
28-
return true;
29-
}
30-
pointer = pointer.parent;
31-
}
32-
return false;
33-
}
34-
35-
function metaForEachMixins(meta: Meta, fn: (mixin: any) => void): void {
36-
let pointer: Meta | null = meta;
37-
38-
let seen: Set<any> | undefined;
39-
while (pointer !== null) {
40-
let set = pointer._mixins;
41-
if (set !== undefined) {
42-
seen = seen === undefined ? new Set() : seen;
43-
44-
set.forEach((mixin: any) => {
45-
if (!seen!.has(mixin)) {
46-
seen!.add(mixin);
47-
fn(mixin);
48-
}
49-
});
50-
}
51-
pointer = pointer.parent;
52-
}
53-
}
547
import { observerListenerMetaFor, ROOT, wrap } from '@ember/-internals/utils/lib/super';
558
import { assert } from '@ember/debug';
569
import { DEBUG } from '@glimmer/env';
@@ -294,10 +247,10 @@ function mergeMixins(
294247
);
295248

296249
if (MIXINS.has(currentMixin)) {
297-
if (metaHasMixin(meta, currentMixin)) {
250+
if (meta.hasMixin(currentMixin)) {
298251
continue;
299252
}
300-
metaAddMixin(meta, currentMixin);
253+
meta.addMixin(currentMixin);
301254

302255
let { properties, mixins } = currentMixin;
303256

@@ -639,7 +592,7 @@ export default class Mixin {
639592
return ret;
640593
}
641594

642-
metaForEachMixins(meta, (currentMixin: Mixin) => {
595+
meta.forEachMixins((currentMixin: Mixin) => {
643596
// skip primitive mixins since these are always anonymous
644597
if (!currentMixin.properties) {
645598
ret.push(currentMixin);
@@ -711,7 +664,7 @@ export default class Mixin {
711664
if (meta === null) {
712665
return false;
713666
}
714-
return metaHasMixin(meta, this);
667+
return meta.hasMixin(this);
715668
}
716669

717670
/** @internal */

packages/@glimmer/runtime/lib/opcodes-debug-setup.ts

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)