Skip to content

Commit

Permalink
refactor: remove redundant string operation (#2394)
Browse files Browse the repository at this point in the history
* refactor: remove redundant string operation

* remove empty comment
  • Loading branch information
zielint0 authored and surli committed Aug 20, 2018
1 parent a1672d6 commit 58d091f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ protected InputStream getCompilationUnitInputStream(String path) {
PrettyPrinter printer = new DefaultJavaPrettyPrinter(env);
printer.calculate(cu, toBePrinted);

return new ByteArrayInputStream(printer.getResult().toString().getBytes());
return new ByteArrayInputStream(printer.getResult().getBytes());
}

protected Environment getEnvironment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class JDTTreeBuilderHelper {
*/
static String computeAnonymousName(char[] anonymousQualifiedName) {
final String poolName = CharOperation.charToString(anonymousQualifiedName);
return poolName.substring(poolName.lastIndexOf(CtType.INNERTTYPE_SEPARATOR) + 1, poolName.length());
return poolName.substring(poolName.lastIndexOf(CtType.INNERTTYPE_SEPARATOR) + 1);
}

/**
Expand Down Expand Up @@ -465,7 +465,7 @@ <T> CtFieldAccess<T> createFieldAccess(FieldReference fieldReference) {
CtTypeAccess<?> createTypeAccess(QualifiedNameReference qualifiedNameReference, CtFieldReference<?> fieldReference) {
final TypeBinding receiverType = qualifiedNameReference.actualReceiverType;
if (receiverType != null) {
final CtTypeReference<Object> qualifiedRef = jdtTreeBuilder.getReferencesBuilder().getQualifiedTypeReference(//
final CtTypeReference<Object> qualifiedRef = jdtTreeBuilder.getReferencesBuilder().getQualifiedTypeReference(
qualifiedNameReference.tokens, receiverType, qualifiedNameReference.fieldBinding().declaringClass.enclosingType(), new JDTTreeBuilder.OnAccessListener() {
@Override
public boolean onAccess(char[][] tokens, int index) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/spoon/test/generics/GenericsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void testBugCommonCollection() throws Exception {
.getActualClass());
pp.visitCtTypeReference(ref);

assertEquals("java.util.Map.Entry", pp.getResult().toString());
assertEquals("java.util.Map.Entry", pp.getResult());

CtField<?> y = type.getElements(new NamedElementFilter<>(CtField.class,"y"))
.get(0);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/spoon/test/prettyprinter/LinesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void testPrettyPrinterWithLines() {
// contract: in line preserve mode, toString is not prefixed or suffixed by newlines
String meth = factory.Type().get("spoon.test.prettyprinter.testclasses.Validation").getMethodsByName("isIdentifier").get(0).toString();
// the added linebreaks due to line preservation are removed
assertFalse(Pattern.compile("^\\s", Pattern.DOTALL).asPredicate().test(meth.toString()));
assertFalse(Pattern.compile("^\\s", Pattern.DOTALL).asPredicate().test(meth));

}

Expand Down

0 comments on commit 58d091f

Please sign in to comment.