antlr / stringtemplate4

StringTemplate 4
http://www.stringtemplate.org
Other
955 stars 231 forks source link

Fix signature of STGroup.getAttributeRenderer #237

Closed Clashsoft closed 4 years ago

Clashsoft commented 4 years ago

This amends #233 with a minor change to the signature of STGroup#getAttributeRenderer, as requested by @sharwell.

Clashsoft commented 4 years ago

@sharwell I think in this case just suppressing the warnings is better than adding the Class#cast overhead, which is totally unnecessary because attributeType == o.getClass(). Since the method is small and local, the suppression wont hurt anyone.

sharwell commented 4 years ago

The call to cast is negligible. It's a JIT intrinsic with a fast path return for the case where the types are equal:

https://github.com/unofficial-openjdk/openjdk/blob/531ef5d0ede6d733b00c9bc1b6b3c14a0b2b3e81/src/hotspot/share/ci/ciKlass.cpp#L72-L75

I would prefer to use the stronger typing in the absence of proof of a problem (demonstrated performance problem via benchmarks).

parrt commented 4 years ago

Thanks guys!