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.
例如,我有一个无限的 while 循环,它不断将 true 分配给我们的 testBool:
boolean testBool; while(true) { testBool = true; ...more logic... }
我们是否在为我们的数据类型重新分配相同的值而浪费计算,或者语言是否足够聪明以识别这种低效率?
一个聪明的编译器会把它拉出循环。
https://en.wikipedia.org/wiki/Loop-invariant_code_motion