net.sourceforge.pmd.rules.strings

Class InefficientEmptyStringCheck

public class InefficientEmptyStringCheck extends AbstractRule

This rule finds code which inefficiently determines empty strings. This code

     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));
 

Author: acaplan

Method Summary
Objectvisit(ASTVariableDeclaratorId node, Object data)

Method Detail

visit

public Object visit(ASTVariableDeclaratorId node, Object data)