Browse Source

readFully(), then index into a char[], rather than calling substring(1) after each read() call

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1090450 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 14 years ago
parent
commit
4b3719fe42
1 changed files with 16 additions and 25 deletions
  1. +16
    -25
      src/main/org/apache/tools/ant/filters/ExpandProperties.java

+ 16
- 25
src/main/org/apache/tools/ant/filters/ExpandProperties.java View File

@@ -42,8 +42,10 @@ public final class ExpandProperties
extends BaseFilterReader
implements ChainableReader {

/** Data that must be read from, if not null. */
private String queuedData = null;
private static final int EOF = -1;

private char[] buffer;
private int index;
private PropertySet propertySet;

/**
@@ -89,24 +91,9 @@ public final class ExpandProperties
* during reading
*/
public int read() throws IOException {

int ch = -1;

if (queuedData != null && queuedData.length() == 0) {
queuedData = null;
}

if (queuedData != null) {
ch = queuedData.charAt(0);
queuedData = queuedData.substring(1);
if (queuedData.length() == 0) {
queuedData = null;
}
} else {
queuedData = readFully();
if (queuedData == null || queuedData.length() == 0) {
ch = -1;
} else {
if (index > EOF) {
if (buffer == null) {
String data = readFully();
Project project = getProject();
GetProperty getProperty;
if (propertySet == null) {
@@ -114,18 +101,22 @@ public final class ExpandProperties
} else {
final Properties props = propertySet.getProperties();
getProperty = new GetProperty() {
public Object getProperty(String name) {
return props.getProperty(name);
}
};
}
queuedData = new ParseProperties(project, PropertyHelper.getPropertyHelper(project)
.getExpanders(), getProperty).parseProperties(queuedData).toString();
return read();
buffer = new ParseProperties(project, PropertyHelper.getPropertyHelper(project)
.getExpanders(), getProperty).parseProperties(data).toString()
.toCharArray();
}
if (index < buffer.length) {
return buffer[index++];
}
index = EOF;
}
return ch;
return EOF;
}

/**


Loading…
Cancel
Save