Skip to content

Commit 96bb74f

Browse files
committed
Simplify fix
1 parent aabbb00 commit 96bb74f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/dirty/checking/DirtyCheckable.groovy

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ trait DirtyCheckable {
7878
void markDirty(String propertyName, newValue) {
7979
if( $changedProperties != null && !$changedProperties.containsKey(propertyName)) {
8080
def oldValue = ((GroovyObject) this).getProperty(propertyName)
81-
if ((newValue == null && oldValue != null) ||
82-
(newValue != null && oldValue == null) ||
83-
(newValue != null && !newValue.equals(oldValue))) {
81+
boolean isNull = newValue == null
82+
if ((isNull && oldValue != null) ||
83+
(!isNull && oldValue == null) ||
84+
(!isNull && !newValue.equals(oldValue))) {
8485
$changedProperties.put propertyName, oldValue
8586
}
8687
}
@@ -93,9 +94,10 @@ trait DirtyCheckable {
9394
*/
9495
void markDirty(String propertyName, newValue, oldValue) {
9596
if( $changedProperties != null && !$changedProperties.containsKey(propertyName)) {
96-
if ((newValue == null && oldValue != null) ||
97-
(newValue != null && oldValue == null) ||
98-
(newValue != null && !newValue.equals(oldValue))) {
97+
boolean isNull = newValue == null
98+
if ((isNull && oldValue != null) ||
99+
(!isNull && oldValue == null) ||
100+
(!isNull && !newValue.equals(oldValue))) {
99101
$changedProperties.put propertyName, oldValue
100102
}
101103
}

0 commit comments

Comments
 (0)