You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[6.0] Performance improvements for SyntaxRewriter (#2742)
* [SyntaxRewriter] Optimize SyntaxRewriter visitation
Similar treatment as 'SyntaxVisitor'. Reuse `Syntax.Info` when it's safe
to do so (i.e. uniquely referenced)
(cherry picked from commit 6be8e8d)
* [SyntaxRewriter] Introduce SyntaxNodeFactory
Factor out 'Syntax.Info' reusing into 'SyntaxNodeFactory' and
'SyntaxInfoRepository' as the backing storage.
The underlying storage now uses a fixed length 'ManagedBuffer' to avoid
'ContiguousArray' overhead.
(cherry picked from commit b6898d1)
* [SyntaxRewriter] Improve new layout node creation
Use manually allocated 'UnsafeBufferPointer' to avoid 'ContiguousArray'
overhead. Pre-initialize the buffer with the "old" layout at once, and
update each element only when updated.
(cherry picked from commit e664473)
* [SyntaxRewriter] Make 'visitChildren()' a non-generic mehod
This was a generic function only for casting the result at the end.
Hoist the casting part to the caller and make 'visitChilden()'
non-generic.
(cherry picked from commit e2d4423)
* [SyntaxRewriter] Iterate RawSyntaxChildren using pattern matching
Simpify the iteration code.
Also, stop counting 'childIndex' as it can be retrieved from the
absolute info.
(cherry picked from commit b67e899)
* [SyntaxVisitor] Adopt SyntaxNodeFactory
Use 'SyntaxNodeFactory' in 'SyntaxVisitor' too. Thanks to the simplified
implementation, it improves the performance a bit.
(cherry picked from commit 7298fe8)
* [SyntaxRewriter] Return the node as-is
There's no performance reason to return 'nil'
(cherry picked from commit ef8bb05)
* [CMake] Split 'touch' workaround into two commands
Workaround for Windows command line length limitation
(cherry picked from commit ec96b4d)
* [Syntax] Mark the parameter of casting initializers '__shared'
Initializer parameters are "+1" in caller site, but these casting
initializers only uses the ._syntaxNode and don't store the parameter itself.
(cherry picked from commit 99b670f)
* [Syntax] Mark parameter of Syntax.init(_:) casting function
Similar to `SyntaxProtocol.init()` initializers.
(cherry picked from commit c5526ac)
* [SyntaxNode] Make 'static var structure' immutable stored properties
Returnning array literal from computed property allocates and
initializes the array buffer every time it's called, and they are
deallocated after use.
Make them stored properties so they stay in memory.
(cherry picked from commit 92dbbf8)
* [Operators] Make OpeatorTable.standardOperators a stored property
Building standard operator table is not trivial. Make is an immutable
stored property so it stays in memory once it's initialized.
(cherry picked from commit fad2743)
0 commit comments