Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
typeof处理复杂表达式时效率如何?
typeof
具体来说,在这两种情况下:
完全由常量部分组成的复杂表达式,不需要CTFE 进行评估
需要mixin()CTFE 字符串的复杂表达式。
mixin()
我不知道这是否有根本的不同,但这是我关心的两种情况。
这取决于您是否对运行时效率或编译时效率感兴趣。typeof(expr)运行时开销为零,它在编译时被完全评估。
typeof(expr)
编译时间复杂度相当低,所以一般不需要担心。