Skip to content

Commit

Permalink
Use StringBuilder to aggregate the field data, which gives an huge pe…
Browse files Browse the repository at this point in the history
…rformance boost for SD file where multiline field data is found.

Signed-off-by: rajarshi <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Oct 1, 2009
1 parent eac8266 commit df35f02
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/org/openscience/cdk/io/MDLV2000Reader.java
Expand Up @@ -264,22 +264,22 @@ private IChemFile readChemFile(IChemFile chemFile) throws CDKException {
if (line == null) {
throw new CDKException("Expecting data line here, but found null!");
}
String data = line;
StringBuilder data = new StringBuilder();
while ((line = input.readLine()) != null &&
line.trim().length() > 0) {
if (line.equals("$$$$")) {
logger.error("Expecting data line here, but found end of molecule: ", line);
break;
}
logger.debug("data line: ", line);
data += line;
data.append(line);
// preserve newlines, unless the line is exactly 80 chars; in that case it
// is assumed to continue on the next line. See MDL documentation.
if (line.length() < 80) data += System.getProperty("line.separator");
if (line.length() < 80) data.append(System.getProperty("line.separator"));
}
if (fieldName != null) {
logger.info("fieldName, data: ", fieldName, ", ", data);
m.setProperty(fieldName, data);
m.setProperty(fieldName, data.toString());
}
}
}
Expand Down

0 comments on commit df35f02

Please sign in to comment.