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