avoid stream to array copying

master
Egor.Ushakov 8 years ago
parent 0255eb3ba5
commit 6a09fe2524
  1. 4
      src/org/jetbrains/java/decompiler/struct/StructMember.java
  2. 7
      src/org/jetbrains/java/decompiler/struct/attr/StructAnnDefaultAttribute.java
  3. 7
      src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationAttribute.java
  4. 8
      src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationParameterAttribute.java
  5. 7
      src/org/jetbrains/java/decompiler/struct/attr/StructBootstrapMethodsAttribute.java
  6. 7
      src/org/jetbrains/java/decompiler/struct/attr/StructConstantValueAttribute.java
  7. 6
      src/org/jetbrains/java/decompiler/struct/attr/StructEnclosingMethodAttribute.java
  8. 7
      src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java
  9. 11
      src/org/jetbrains/java/decompiler/struct/attr/StructGeneralAttribute.java
  10. 7
      src/org/jetbrains/java/decompiler/struct/attr/StructGenericSignatureAttribute.java
  11. 8
      src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java
  12. 6
      src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java
  13. 6
      src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTableAttribute.java
  14. 4
      src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTypeTableAttribute.java
  15. 7
      src/org/jetbrains/java/decompiler/struct/attr/StructSourceFileAttribute.java
  16. 7
      src/org/jetbrains/java/decompiler/struct/attr/StructTypeAnnotationAttribute.java

@ -84,9 +84,7 @@ public class StructMember {
in.discard(length);
}
else {
byte[] data = in.read(length);
attribute.setInfo(data);
attribute.initContent(pool);
attribute.initContent(in, pool);
}
return attribute;
}

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@ package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.IOException;
@ -25,8 +26,8 @@ public class StructAnnDefaultAttribute extends StructGeneralAttribute {
private Exprent defaultValue;
@Override
public void initContent(ConstantPool pool) throws IOException {
defaultValue = StructAnnotationAttribute.parseAnnotationElement(stream(), pool);
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
defaultValue = StructAnnotationAttribute.parseAnnotationElement(data, pool);
}
public Exprent getDefaultValue() {

@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,6 +21,7 @@ import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.struct.consts.PrimitiveConstant;
import org.jetbrains.java.decompiler.struct.gen.FieldDescriptor;
import org.jetbrains.java.decompiler.struct.gen.VarType;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.DataInputStream;
import java.io.IOException;
@ -32,8 +33,8 @@ public class StructAnnotationAttribute extends StructGeneralAttribute {
private List<AnnotationExprent> annotations;
@Override
public void initContent(ConstantPool pool) throws IOException {
annotations = parseAnnotations(pool, stream());
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
annotations = parseAnnotations(pool, data);
}
public static List<AnnotationExprent> parseAnnotations(ConstantPool pool, DataInputStream data) throws IOException {

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,8 +17,8 @@ package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.modules.decompiler.exps.AnnotationExprent;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@ -29,9 +29,7 @@ public class StructAnnotationParameterAttribute extends StructGeneralAttribute {
private List<List<AnnotationExprent>> paramAnnotations;
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int len = data.readUnsignedByte();
if (len > 0) {
paramAnnotations = new ArrayList<>(len);

@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.struct.consts.LinkConstant;
import org.jetbrains.java.decompiler.struct.consts.PooledConstant;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.DataInputStream;
import java.io.IOException;
@ -30,9 +31,7 @@ public class StructBootstrapMethodsAttribute extends StructGeneralAttribute {
private final List<List<PooledConstant>> methodArguments = new ArrayList<>();
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int method_number = data.readUnsignedShort();
for (int i = 0; i < method_number; ++i) {

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.IOException;
@ -24,8 +25,8 @@ public class StructConstantValueAttribute extends StructGeneralAttribute {
private int index;
@Override
public void initContent(ConstantPool pool) throws IOException {
index = stream().readUnsignedShort();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
index = data.readUnsignedShort();
}
public int getIndex() {

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@ package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.struct.consts.LinkConstant;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.DataInputStream;
import java.io.IOException;
@ -28,8 +29,7 @@ public class StructEnclosingMethodAttribute extends StructGeneralAttribute {
private String methodDescriptor;
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int classIndex = data.readUnsignedShort();
int methodIndex = data.readUnsignedShort();

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@ -28,8 +28,7 @@ public class StructExceptionsAttribute extends StructGeneralAttribute {
private List<Integer> throwsExceptions;
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int len = data.readUnsignedShort();
if (len > 0) {
throwsExceptions = new ArrayList<>(len);

@ -50,7 +50,6 @@ public class StructGeneralAttribute {
public static final String ATTRIBUTE_SOURCE_FILE = "SourceFile";
private String name;
private byte[] info;
public static StructGeneralAttribute createAttribute(String name) {
StructGeneralAttribute attr;
@ -109,15 +108,7 @@ public class StructGeneralAttribute {
return attr;
}
protected DataInputFullStream stream() {
return new DataInputFullStream(info);
}
public void initContent(ConstantPool pool) throws IOException { }
public void setInfo(byte[] info) {
this.info = info;
}
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { }
public String getName() {
return name;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.IOException;
@ -24,8 +25,8 @@ public class StructGenericSignatureAttribute extends StructGeneralAttribute {
private String signature;
@Override
public void initContent(ConstantPool pool) throws IOException {
int index = stream().readUnsignedShort();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int index = data.readUnsignedShort();
signature = pool.getPrimitiveConstant(index).getString();
}

@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@ -47,9 +47,7 @@ public class StructInnerClassesAttribute extends StructGeneralAttribute {
private List<Entry> entries;
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int len = data.readUnsignedShort();
if (len > 0) {
entries = new ArrayList<>(len);

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,9 +33,7 @@ public class StructLineNumberTableAttribute extends StructGeneralAttribute {
private int[] myLineInfo = InterpreterUtil.EMPTY_INT_ARRAY;
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputFullStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int len = data.readUnsignedShort() * 2;
if (len > 0) {
myLineInfo = new int[len];

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,9 +38,7 @@ public class StructLocalVariableTableAttribute extends StructGeneralAttribute {
private Map<Integer, String> mapVarNames = Collections.emptyMap();
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputFullStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int len = data.readUnsignedShort();
if (len > 0) {
mapVarNames = new HashMap<>(len);

@ -37,9 +37,7 @@ public class StructLocalVariableTypeTableAttribute extends StructGeneralAttribut
private Map<Integer, String> mapVarSignatures = Collections.emptyMap();
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputFullStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int len = data.readUnsignedShort();
if (len > 0) {
mapVarSignatures = new HashMap<>(len);

@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.IOException;
@ -24,8 +25,8 @@ public class StructSourceFileAttribute extends StructGeneralAttribute {
private String fileName;
@Override
public void initContent(ConstantPool pool) throws IOException {
int index = stream().readUnsignedShort();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int index = data.readUnsignedShort();
fileName = pool.getPrimitiveConstant(index).getString();
}

@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.modules.decompiler.exps.AnnotationExprent;
import org.jetbrains.java.decompiler.modules.decompiler.exps.TypeAnnotation;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.DataInputStream;
import java.io.IOException;
@ -29,9 +30,7 @@ public class StructTypeAnnotationAttribute extends StructGeneralAttribute {
private List<TypeAnnotation> annotations = Collections.emptyList();
@Override
public void initContent(ConstantPool pool) throws IOException {
DataInputStream data = stream();
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int len = data.readUnsignedShort();
if (len > 0) {
annotations = new ArrayList<>(len);

Loading…
Cancel
Save