net.sourceforge.pmd.rules.strings
public class InefficientEmptyStringCheck extends AbstractInefficientZeroCheck
if(str.trim().length()==0){....is quite inefficient as trim() causes a new String to be created. Smarter code to check for an empty string would be:
Character.isWhitespace(str.charAt(i));
Method Summary | |
---|---|
boolean | appliesToClassName(String name) |
boolean | isTargetMethod(NameOccurrence occ)
Determine if we're dealing with String.length method
|
Parameters: occ The name occurance
Returns: true if it's String.length, else false