[Fb-contrib-commit] SF.net SVN: fb-contrib: [916] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-09-19 04:45:52
|
Revision: 916 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=916&view=rev Author: dbrosius Date: 2007-09-18 21:45:54 -0700 (Tue, 18 Sep 2007) Log Message: ----------- find new StringBuilder(a + "1") Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 01:52:13 UTC (rev 915) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 04:45:54 UTC (rev 916) @@ -81,18 +81,27 @@ if (seen == INVOKESPECIAL) { String calledClass = getClassConstantOperand(); + String signature = getSigConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) || "java/lang/StringBuilder".equals(calledClass)) - && "<init>".equals(getNameConstantOperand()) - && "()V".equals(getSigConstantOperand())) { - OpcodeStack.Item itm = getStringBufferItemAt(2); - if (itm != null) { - nestedSB = Boolean.TRUE; - } else { - itm = getStringBufferItemAt(1); + && "<init>".equals(getNameConstantOperand())) { + if ("()V".equals(signature)) { + OpcodeStack.Item itm = getStringBufferItemAt(2); if (itm != null) { nestedSB = Boolean.TRUE; } + } else if ("(Ljava/lang/String;)V".equals(signature)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + nestedSB = (Boolean)itm.getUserValue(); + if (nestedSB != null) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } } } else if (seen == INVOKEVIRTUAL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |