[Fb-contrib-commit] SF.net SVN: fb-contrib: [861] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-02-17 07:43:47
|
Revision: 861 http://svn.sourceforge.net/fb-contrib/?rev=861&view=rev Author: dbrosius Date: 2007-02-16 23:43:47 -0800 (Fri, 16 Feb 2007) Log Message: ----------- revert - that was a disaster 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-02-17 06:41:09 UTC (rev 860) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 07:43:47 UTC (rev 861) @@ -75,11 +75,25 @@ @Override public void sawOpcode(final int seen) { - boolean markAsSBToString = false; try { stack.mergeJumps(this); - if (seen == INVOKEVIRTUAL) { + if (seen == INVOKESPECIAL) { + String calledClass = getClassConstantOperand(); + 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) && (itm.getUserValue() == null)) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } else if (seen == INVOKEVIRTUAL) { if (sawLDCEmpty) { String calledClass = getClassConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) @@ -104,52 +118,12 @@ } } } - } else { - String calledClass = getClassConstantOperand(); - if (("java/lang/StringBuffer".equals(calledClass) - || "java/lang/StringBuilder".equals(calledClass))) { - if (("toString".equals(getNameConstantOperand()) - && "()Ljava/lang/String;".equals(getSigConstantOperand()))) { - markAsSBToString = true; - } else if (("append".equals(getNameConstantOperand()) - && (("(Ljava/lang/String;)L" + calledClass + ";").equals(getSigConstantOperand())))) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(0); - Boolean sbVal = (Boolean)itm.getUserValue(); - if ((sbVal != null) && sbVal.booleanValue()) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } - } } - } else if (seen == INVOKESPECIAL) { - String calledClass = getClassConstantOperand(); - if (("java/lang/StringBuffer".equals(calledClass) - || "java/lang/StringBuilder".equals(calledClass)) - && "<init>".equals(getNameConstantOperand()) - && "(Ljava/lang/String;)V".equals(getSigConstantOperand())) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(0); - Boolean sbVal = (Boolean)itm.getUserValue(); - if ((sbVal != null) && sbVal.booleanValue()) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } } else if (seen == GOTO) { int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { OpcodeStack.Item itm = stack.getStackItem(i); - itm.setUserValue(Boolean.FALSE); + itm.setUserValue(Boolean.TRUE); } } else if (seen == LDC) { Constant c = getConstantRefOperand(); @@ -161,12 +135,6 @@ } } finally { stack.sawOpcode(this, seen); - if (markAsSBToString) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - itm.setUserValue(Boolean.TRUE); - } - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |