Open osa1 opened 2 years ago
It may need to be @pragma('dart2js:tryInline')
. It could also be written with explicit as
check and using @pragma('dart2js:as:trust')
.
Another consideration is the debug performance in DDC which never inlines methods.
It might be better to put @pragma('dart2js:as:trust')
on the method that contains the cast rather than add an 'abstraction'.
I recently added some documentation of the dart2js pragmas: https://dart.googlesource.com/sdk/+/f503281917b74ac0571bd4bc5c37789006cdef8e/pkg/compiler/doc/pragmas.md
In protobuf library, for downcasting we use implicit cast syntax:
instead of explicit cast syntax:
The reason is because dart2js compiles these two differently, and the implicit cast syntax is much more efficient.
(AOT and JIT treat both the same way)
For a reader it won't be obvious why we do this. We should create a function for downcasting that uses implicit cast syntax, and document why we use it. @mkustermann suggests