fix replace() with nulls

This commit is contained in:
Ben Fry
2014-10-28 11:52:35 -04:00
parent 53e348b597
commit f27da8509b

View File

@@ -3435,9 +3435,18 @@ public class Table {
public void replace(String orig, String replacement, int col) {
if (columnTypes[col] == STRING) {
String[] stringData = (String[]) columns[col];
for (int row = 0; row < rowCount; row++) {
if (stringData[row].equals(orig)) {
stringData[row] = replacement;
if (orig != null) {
for (int row = 0; row < rowCount; row++) {
if (orig.equals(stringData[row])) {
stringData[row] = replacement;
}
}
} else { // null is a special case (and faster anyway)
for (int row = 0; row < rowCount; row++) {
if (stringData[row] == null) {
stringData[row] = replacement;
}
}
}
}