Investigate removing the concept of object allocators #52958
Labels
Committed
The team has roadmapped this issue
Domain: Performance
Reports of unusually slow behavior
Experimentation Needed
Someone needs to try this out to see what happens
Infrastructure
Issue relates to TypeScript team infrastructure
Suggestion
An idea for TypeScript
Milestone
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.
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,
Node
s constructed by the language service have methods likegetStart()
,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.
The text was updated successfully, but these errors were encountered: