Investigate removing the concept of object allocators
@rbuckton arbeitet bereits daran.
Seit 25.2.2023.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
Today we have the concept of an "object allocator". This is basically a set of functions, each which returns a constructor function for a commonly used data structure in the compiler.
/** @internal */
export interface ObjectAllocator {
getNodeConstructor(): new (kind: SyntaxKind, pos: number, end: number) => Node;
getTokenConstructor(): new <TKind extends SyntaxKind>(kind: TKind, pos: number, end: number) => Token<TKind>;
getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos: number, end: number) => Identifier;
getPrivateIdentifierConstructor(): new (kind: SyntaxKind.PrivateIdentifier, pos: number, end: number) => PrivateIdentifier;
getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos: number, end: number) => SourceFile;
getSymbolConstructor(): new (flags: SymbolFlags, name: __String) => Symbol;
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
getSignatureConstructor(): new (checker: TypeChecker, flags: SignatureFlags) => Signature;
getSourceMapSourceConstructor(): new (fileName: string, text: string, skipTrivia?: (pos: number) => number) => SourceMapSource;
}
Why do this? Because for our batch compiler, TypeScript uses constructors with more bare-bones objects. For the most part, there are no members on the prototype, and we work purely with instance-set data.
On the other hand, the language service and TypeScript's API provides constructors that are attached to richer prototypes. For example, Nodes constructed by the language service have methods like getStart(), getEnd(), getSourceFile(), etc. These are partially for convenience and if my memory serves correctly, partially to power backwards-compatibility going back to TypeScript 1.0's tree API.
However, managing the two is slightly annoying, and creates layers of indirection. It would be nice to see if we can move away from this indirection and whether it can eliminate runtime overhead at all.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/TypeScript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64322 · 2 Kommentare · 1 Reaktion · 2 zugewiesene Personen ·
-
Possible Improvement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
microsoft/TypeScript#64278 · 1 Kommentar · 1 Reaktion ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
microsoft/TypeScript#64118 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64094 ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/TypeScript#63959 · 5 Kommentare ·
Alle Issues in microsoft/TypeScript
Ähnliche Issues
-
optimization optimization:agents-md-curator
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
githubnext/gh-aw-cao#13143 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
blinklabs-io/bursa#904 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 Kommentare ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100