Skip to content

Commit

Permalink
replaced StringBuffer with StringBuilder in tar lib
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6213 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Jul 14, 2009
1 parent 49bbb9b commit aee35bf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
42 changes: 23 additions & 19 deletions source/org/apache/tools/tar/TarEntry.java
Expand Up @@ -20,6 +20,10 @@
* This package is based on the work done by Timothy Gerard Endres
* (time@ice.com) to whom the Ant project is very grateful for his great code.
*/
/*
* Modifications (Michael Christen)
* - replaced StringBuffer with StringBuilder
*/

package org.apache.tools.tar;

Expand Down Expand Up @@ -78,7 +82,7 @@

public class TarEntry implements TarConstants {
/** The entry's name. */
private StringBuffer name;
private StringBuilder name;

/** The entry's permission mode. */
private int mode;
Expand All @@ -99,16 +103,16 @@ public class TarEntry implements TarConstants {
private byte linkFlag;

/** The entry's link name. */
private StringBuffer linkName;
private StringBuilder linkName;

/** The entry's magic tag. */
private StringBuffer magic;
private StringBuilder magic;

/** The entry's user name. */
private StringBuffer userName;
private StringBuilder userName;

/** The entry's group name. */
private StringBuffer groupName;
private StringBuilder groupName;

/** The entry's major device number. */
private int devMajor;
Expand All @@ -135,9 +139,9 @@ public class TarEntry implements TarConstants {
* Construct an empty entry and prepares the header values.
*/
private TarEntry () {
this.magic = new StringBuffer(TMAGIC);
this.name = new StringBuffer();
this.linkName = new StringBuffer();
this.magic = new StringBuilder(TMAGIC);
this.name = new StringBuilder();
this.linkName = new StringBuilder();

String user = System.getProperty("user.name", "");

Expand All @@ -147,8 +151,8 @@ private TarEntry () {

this.userId = 0;
this.groupId = 0;
this.userName = new StringBuffer(user);
this.groupName = new StringBuffer("");
this.userName = new StringBuilder(user);
this.groupName = new StringBuilder("");
this.file = null;
}

Expand All @@ -165,16 +169,16 @@ public TarEntry(String name) {

this.devMajor = 0;
this.devMinor = 0;
this.name = new StringBuffer(name);
this.name = new StringBuilder(name);
this.mode = isDir ? DEFAULT_DIR_MODE : DEFAULT_FILE_MODE;
this.linkFlag = isDir ? LF_DIR : LF_NORMAL;
this.userId = 0;
this.groupId = 0;
this.size = 0;
this.modTime = (new Date()).getTime() / MILLIS_PER_SECOND;
this.linkName = new StringBuffer("");
this.userName = new StringBuffer("");
this.groupName = new StringBuffer("");
this.linkName = new StringBuilder("");
this.userName = new StringBuilder("");
this.groupName = new StringBuilder("");
this.devMajor = 0;
this.devMinor = 0;

Expand Down Expand Up @@ -238,8 +242,8 @@ public TarEntry(File file) {
fileName = fileName.substring(1);
}

this.linkName = new StringBuffer("");
this.name = new StringBuffer(fileName);
this.linkName = new StringBuilder("");
this.name = new StringBuilder(fileName);

if (file.isDirectory()) {
this.mode = DEFAULT_DIR_MODE;
Expand Down Expand Up @@ -331,7 +335,7 @@ public String getName() {
* @param name This entry's new name.
*/
public void setName(String name) {
this.name = new StringBuffer(name);
this.name = new StringBuilder(name);
}

/**
Expand Down Expand Up @@ -403,7 +407,7 @@ public String getUserName() {
* @param userName This entry's new user name.
*/
public void setUserName(String userName) {
this.userName = new StringBuffer(userName);
this.userName = new StringBuilder(userName);
}

/**
Expand All @@ -421,7 +425,7 @@ public String getGroupName() {
* @param groupName This entry's new group name.
*/
public void setGroupName(String groupName) {
this.groupName = new StringBuffer(groupName);
this.groupName = new StringBuilder(groupName);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion source/org/apache/tools/tar/TarInputStream.java
Expand Up @@ -20,6 +20,10 @@
* This package is based on the work done by Timothy Gerard Endres
* (time@ice.com) to whom the Ant project is very grateful for his great code.
*/
/*
* Modifications (Michael Christen)
* - replaced StringBuffer with StringBuilder
*/

package org.apache.tools.tar;

Expand Down Expand Up @@ -258,7 +262,7 @@ public TarEntry getNextEntry() throws IOException {

if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) {
// read in the name
StringBuffer longName = new StringBuffer();
StringBuilder longName = new StringBuilder();
byte[] buf = new byte[SMALL_BUFFER_SIZE];
int length = 0;
while ((length = read(buf)) >= 0) {
Expand Down
10 changes: 7 additions & 3 deletions source/org/apache/tools/tar/TarUtils.java
Expand Up @@ -20,6 +20,10 @@
* This package is based on the work done by Timothy Gerard Endres
* (time@ice.com) to whom the Ant project is very grateful for his great code.
*/
/*
* Modifications (Michael Christen)
* - replaced StringBuffer with StringBuilder
*/

package org.apache.tools.tar;

Expand Down Expand Up @@ -78,8 +82,8 @@ public static long parseOctal(byte[] header, int offset, int length) {
* @param length The number of header bytes to parse.
* @return The header's entry name.
*/
public static StringBuffer parseName(byte[] header, int offset, int length) {
StringBuffer result = new StringBuffer(length);
public static StringBuilder parseName(byte[] header, int offset, int length) {
StringBuilder result = new StringBuilder(length);
int end = offset + length;

for (int i = offset; i < end; ++i) {
Expand All @@ -102,7 +106,7 @@ public static StringBuffer parseName(byte[] header, int offset, int length) {
* @param length The number of header bytes to parse.
* @return The number of bytes in a header's entry name.
*/
public static int getNameBytes(StringBuffer name, byte[] buf, int offset, int length) {
public static int getNameBytes(StringBuilder name, byte[] buf, int offset, int length) {
int i;

for (i = 0; i < length && i < name.length(); ++i) {
Expand Down

0 comments on commit aee35bf

Please sign in to comment.