mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix: avoid unnecessary attribute lookup
This commit is contained in:
@@ -49,7 +49,7 @@ constructor(
|
||||
updateAttribute(attribute)
|
||||
} else {
|
||||
this.attributes.add(attribute)
|
||||
updateAttribute(attribute)
|
||||
applyAttribute(attribute)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,14 @@ constructor(
|
||||
override fun updateAttribute(attribute: IAttribute) {
|
||||
val existing = findAttribute(attribute) ?: throw IllegalArgumentException("Attribute '${attribute.name}' not found")
|
||||
existing.value = attribute.value
|
||||
applyAttribute(existing)
|
||||
}
|
||||
|
||||
override fun findAttribute(namespaceUri: String, name: String): IAttribute? {
|
||||
return this.attributes.find { it.namespace.uri == namespaceUri && it.name == name }
|
||||
}
|
||||
|
||||
protected open fun applyAttribute(attribute: IAttribute) {
|
||||
val adapter = AttributeAdapterIndex.getAdapter(name)
|
||||
if (adapter == null) {
|
||||
log.warn("No attribute adapter found for view $name")
|
||||
@@ -69,10 +77,6 @@ constructor(
|
||||
adapter.apply(this, attribute)
|
||||
}
|
||||
|
||||
override fun findAttribute(namespaceUri: String, name: String): IAttribute? {
|
||||
return this.attributes.find { it.namespace.uri == namespaceUri && it.name == name }
|
||||
}
|
||||
|
||||
protected open fun hasAttribute(attribute: IAttribute): Boolean {
|
||||
return hasAttribute(attribute.namespace.uri, attribute.name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user