mirror of https://github.com/anoshenko/rui.git
Optimisation
This commit is contained in:
parent
34478c5ff1
commit
d6d243458c
26
data.go
26
data.go
|
|
@ -186,21 +186,25 @@ func (object *dataObject) PropertyByTag(tag string) DataNode {
|
||||||
|
|
||||||
func (object *dataObject) RemovePropertyByTag(tag string) DataNode {
|
func (object *dataObject) RemovePropertyByTag(tag string) DataNode {
|
||||||
if object.property != nil {
|
if object.property != nil {
|
||||||
for i, node := range object.property {
|
index := slices.IndexFunc(object.property, func(node DataNode) bool {
|
||||||
if node.Tag() == tag {
|
return node.Tag() == tag
|
||||||
switch i {
|
})
|
||||||
case 0:
|
|
||||||
object.property = object.property[1:]
|
|
||||||
|
|
||||||
case len(object.property) - 1:
|
if index >= 0 {
|
||||||
object.property = object.property[:len(object.property)-1]
|
node := object.property[index]
|
||||||
|
|
||||||
default:
|
switch index {
|
||||||
object.property = append(object.property[:i], object.property[i+1:]...)
|
case 0:
|
||||||
}
|
object.property = object.property[1:]
|
||||||
|
|
||||||
return node
|
case len(object.property) - 1:
|
||||||
|
object.property = object.property[:len(object.property)-1]
|
||||||
|
|
||||||
|
default:
|
||||||
|
object.property = append(object.property[:index], object.property[index+1:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue