finishing up my commits (7855-7858) which could be helpful for

not declaring inside loops (helps GC of some VMs)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7859 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
sixcooler 14 years ago
parent 9170a434ed
commit a311596881

@ -1390,14 +1390,16 @@ public final class HTTPDFileHandler {
final Pattern p = Pattern.compile("(href=\"|src=\")([^\"]+)|(href='|src=')([^']+)|(url\\(')([^']+)|(url\\(\")([^\"]+)|(url\\()([^\\)]+)");
final Matcher m = p.matcher(sbuffer);
final StringBuffer result = new StringBuffer(80);
String init, url;
MultiProtocolURI target;
while (m.find()) {
String init = null;
init = null;
if(m.group(1) != null) init = m.group(1);
if(m.group(3) != null) init = m.group(3);
if(m.group(5) != null) init = m.group(5);
if(m.group(7) != null) init = m.group(7);
if(m.group(9) != null) init = m.group(9);
String url = null;
url = null;
if(m.group(2) != null) url = m.group(2);
if(m.group(4) != null) url = m.group(4);
if(m.group(6) != null) url = m.group(6);
@ -1423,7 +1425,7 @@ public final class HTTPDFileHandler {
} else {
// relative path of form href="relative/path"
try {
MultiProtocolURI target = new MultiProtocolURI(proxyurl.getHost() + directory + "/" + url);
target = new MultiProtocolURI(proxyurl.getHost() + directory + "/" + url);
m.appendReplacement(result, init + "/proxy.html?url=" + target.toString());
}
catch (MalformedURLException e) {}

@ -832,6 +832,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// format information for further usage
final Map<String, byte[]> files = new HashMap<String, byte[]>();
byte[] fileContent;
for (final FileItem item : items) {
if (item.isFormField()) {
// simple text
@ -845,7 +846,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
} else {
// file
args.put(item.getFieldName(), item.getName());
final byte[] fileContent = FileUtils.read(item.getInputStream());
fileContent = FileUtils.read(item.getInputStream());
item.getInputStream().close();
files.put(item.getFieldName(), fileContent);
}
@ -1261,10 +1262,11 @@ public final class HTTPDemon implements serverHandler, Cloneable {
//read custom headers
final Iterator<ResponseHeader.Entry> it = responseHeader.getAdditionalHeaderProperties().iterator();
ResponseHeader.Entry e;
while(it.hasNext()) {
//Append user properties to the main String
//TODO: Should we check for user properites. What if they intersect properties that are already in header?
final ResponseHeader.Entry e = it.next();
e = it.next();
header.append(e.getKey()).append(": ").append(e.getValue()).append("\r\n");
}

@ -686,8 +686,11 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
// start dialog
byte[] requestBytes = null;
boolean terminate = false;
String reqCmd;
String reqCmd, tmp;
String reqProtocol = "HTTP";
Object result;
Object[] parameter;
Method commandMethod;
final long situationDependentKeepAliveTimeout = keepAliveTimeout;
while (this.in != null &&
this.controlSocket != null &&
@ -706,7 +709,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
// of the commandObject
if (this.request.trim().length() == 0) this.request = "EMPTY";
final Object[] parameter = new Object[2];
parameter = new Object[2];
// get the rest of the request parameters
final int pos = this.request.indexOf(' ');
@ -738,7 +741,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
this.controlSocket.setSoTimeout(this.socketTimeout);
// exec command and return value
Method commandMethod = commandObjMethodCache.get(reqProtocol + "_" + reqCmd);
commandMethod = commandObjMethodCache.get(reqProtocol + "_" + reqCmd);
if (commandMethod == null) {
try {
commandMethod = this.commandObj.getClass().getMethod(reqCmd, sessionCallType);
@ -749,7 +752,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
}
}
Object result = null;
result = null;
try {
result = commandMethod.invoke(this.commandObj, parameter);
} catch (final OutOfMemoryError e) {
@ -786,7 +789,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
}
writeLine((String) result);
} else if (result instanceof InputStream) {
String tmp = send(this.out, (InputStream) result);
tmp = send(this.out, (InputStream) result);
if ((tmp.length() > 4) && (tmp.toUpperCase().startsWith("PASS"))) {
log(true, "PASS ********");
} else {

@ -46,10 +46,10 @@ public class SnippetExtractor {
TreeSet<Integer> positions;
int linenumber = 0;
int fullmatchcounter = 0;
lookup: for (StringBuilder sentence: sentences) {
lookup: for (final StringBuilder sentence: sentences) {
hs = WordTokenizer.hashSentence(sentence.toString(), null);
positions = new TreeSet<Integer>();
for (byte[] word: queryhashes) {
for (final byte[] word: queryhashes) {
pos = hs.get(word);
if (pos != null) {
positions.add(pos);

Loading…
Cancel
Save