Skip to content

Commit cc89b20

Browse files
committed
fix replace() with nulls
1 parent 3d4bf5c commit cc89b20

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

core/src/processing/data/Table.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3435,9 +3435,18 @@ public void replace(String orig, String replacement) {
34353435
public void replace(String orig, String replacement, int col) {
34363436
if (columnTypes[col] == STRING) {
34373437
String[] stringData = (String[]) columns[col];
3438-
for (int row = 0; row < rowCount; row++) {
3439-
if (stringData[row].equals(orig)) {
3440-
stringData[row] = replacement;
3438+
3439+
if (orig != null) {
3440+
for (int row = 0; row < rowCount; row++) {
3441+
if (orig.equals(stringData[row])) {
3442+
stringData[row] = replacement;
3443+
}
3444+
}
3445+
} else { // null is a special case (and faster anyway)
3446+
for (int row = 0; row < rowCount; row++) {
3447+
if (stringData[row] == null) {
3448+
stringData[row] = replacement;
3449+
}
34413450
}
34423451
}
34433452
}

0 commit comments

Comments
 (0)