Skip to content

Commit

Permalink
Simplify array copy
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 29, 2022
1 parent 93d1e13 commit a3efc6f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/main/java/org/apache/bcel/classfile/Code.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ private int calculateLength() {
public Attribute copy(final ConstantPool constantPool) {
final Code c = (Code) clone();
if (code != null) {
c.code = new byte[code.length];
System.arraycopy(code, 0, c.code, 0, code.length);
c.code = code.clone();
}
c.setConstantPool(constantPool);
c.exceptionTable = new CodeException[exceptionTable.length];
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/apache/bcel/classfile/Deprecated.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public void accept(final Visitor v) {
public Attribute copy(final ConstantPool constantPool) {
final Deprecated c = (Deprecated) clone();
if (bytes != null) {
c.bytes = new byte[bytes.length];
System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
c.bytes = bytes.clone();
}
c.setConstantPool(constantPool);
return c;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/apache/bcel/classfile/ExceptionTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ public void accept(final Visitor v) {
public Attribute copy(final ConstantPool constantPool) {
final ExceptionTable c = (ExceptionTable) clone();
if (exceptionIndexTable != null) {
c.exceptionIndexTable = new int[exceptionIndexTable.length];
System.arraycopy(exceptionIndexTable, 0, c.exceptionIndexTable, 0, exceptionIndexTable.length);
c.exceptionIndexTable = exceptionIndexTable.clone();
}
c.setConstantPool(constantPool);
return c;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/apache/bcel/classfile/ModulePackages.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public void accept(final Visitor v) {
public Attribute copy(final ConstantPool constantPool) {
final ModulePackages c = (ModulePackages) clone();
if (packageIndexTable != null) {
c.packageIndexTable = new int[packageIndexTable.length];
System.arraycopy(packageIndexTable, 0, c.packageIndexTable, 0, packageIndexTable.length);
c.packageIndexTable = packageIndexTable.clone();
}
c.setConstantPool(constantPool);
return c;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/apache/bcel/classfile/NestMembers.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public void accept(final Visitor v) {
public Attribute copy(final ConstantPool constantPool) {
final NestMembers c = (NestMembers) clone();
if (classes != null) {
c.classes = new int[classes.length];
System.arraycopy(classes, 0, c.classes, 0, classes.length);
c.classes = classes.clone();
}
c.setConstantPool(constantPool);
return c;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/apache/bcel/classfile/Synthetic.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public void accept(final Visitor v) {
public Attribute copy(final ConstantPool constantPool) {
final Synthetic c = (Synthetic) clone();
if (bytes != null) {
c.bytes = new byte[bytes.length];
System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
c.bytes = bytes.clone();
}
c.setConstantPool(constantPool);
return c;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/apache/bcel/classfile/Unknown.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public void accept(final Visitor v) {
public Attribute copy(final ConstantPool constantPool) {
final Unknown c = (Unknown) clone();
if (bytes != null) {
c.bytes = new byte[bytes.length];
System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
c.bytes = bytes.clone();
}
c.setConstantPool(constantPool);
return c;
Expand Down

0 comments on commit a3efc6f

Please sign in to comment.