Avoid unnecessary comparison
This commit is contained in:
parent
1e68baea9d
commit
34ed1322ba
@ -643,6 +643,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
|
||||
override fun observe(): Boolean {
|
||||
check(!isRemoved) { "Field was removed" }
|
||||
|
||||
if (!isDirty && !codec.compare(remote, field)) {
|
||||
notifyEndpoints(this@Field)
|
||||
isDirty = true
|
||||
@ -669,10 +670,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
return
|
||||
}
|
||||
|
||||
if (this.field == value) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!isDirty && !codec.compare(remote, value)) {
|
||||
notifyEndpoints(this@Field)
|
||||
isDirty = true
|
||||
@ -726,6 +723,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
|
||||
override fun observe(): Boolean {
|
||||
check(!isRemoved) { "Field was removed" }
|
||||
|
||||
val value = value
|
||||
|
||||
if (!isDirty && (remote == null || !codec.compare(remote ?: throw ConcurrentModificationException(), value))) {
|
||||
notifyEndpoints(this)
|
||||
isDirty = true
|
||||
@ -746,7 +746,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
|
||||
override fun write(stream: DataOutputStream, endpoint: Endpoint) {
|
||||
check(!isRemoved) { "Field was removed" }
|
||||
val value = value
|
||||
codec.write(stream, value)
|
||||
isDirty = false
|
||||
}
|
||||
@ -795,6 +794,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
override fun observe(): Boolean {
|
||||
check(!isRemoved) { "Field was removed" }
|
||||
|
||||
val value = value
|
||||
|
||||
if (!isDirty && !codec.compare(remote, value)) {
|
||||
notifyEndpoints(this)
|
||||
isDirty = true
|
||||
@ -812,7 +813,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
|
||||
override fun write(stream: DataOutputStream, endpoint: Endpoint) {
|
||||
check(!isRemoved) { "Field was removed" }
|
||||
val value = value
|
||||
codec.write(stream, value)
|
||||
isDirty = false
|
||||
}
|
||||
@ -835,8 +835,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
private var isRemote = false
|
||||
|
||||
init {
|
||||
if (observingBackingMap != null)
|
||||
if (observingBackingMap != null) {
|
||||
observers.add(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun pushBacklog(key: Any?, value: (DataOutputStream) -> Unit) {
|
||||
|
Loading…
Reference in New Issue
Block a user