eclipse-emf / org.eclipse.emf

Eclipse Public License 2.0
10 stars 13 forks source link

Use typed for-each loop #6

Closed jukzi closed 1 year ago

jukzi commented 1 year ago

Avoiding type-casts makes code easier to read.

merks commented 1 year ago

Does it make the code perform better or are there hidden type casts that aren’t needed yet are paid for? I expect the latter and the code runs much more often than someone reads it.

jukzi commented 1 year ago

It's just the result of a static code analysis. Nothing meaningful, however typesafe. i don't know what exactly you fear. But it would also be ok for me to not change anything.

merks commented 1 year ago

I'll need to look at each change in context, when I have time, decide if it's in a performance sensitive area. Mostly I think that's not the case, and it looks like there are even cases where there are casts anyway...

merks commented 1 year ago

Except for the XMLTypeFactoryImpl changes the other places are relatively performance sensitive and, in each case, within the body of the loop, the typed value is not actually used nor needed, so better to avoid the cost of the implicit cast. For the XMLTypeFactoryImpl changes, these methods are generated so should be fixed in the generator to generate the improved style. That change has been committed.

Thanks for drawing attention to this. 😃