Skip to content

Files

Latest commit

 

History

History
23 lines (14 loc) · 630 Bytes

UnnecessaryTemporaryInstantiation.md

File metadata and controls

23 lines (14 loc) · 630 Bytes

Pattern: Unnecessary temporary instantiation

Issue: -

Description

Avoid temporary objects when converting primitive types to String. This has a performance penalty when compared to using primitive types directly. To solve this issue, remove the wrapping type.

Example of incorrect code:

val i = Integer(1).toString() // temporary Integer instantiation just for the conversion

Example of correct code:

val i = Integer.toString(1)

Further Reading