mirror of https://github.com/anoshenko/rui.git
Optimisation
This commit is contained in:
parent
cb4d197bb7
commit
d633c80155
6
data.go
6
data.go
|
@ -384,7 +384,8 @@ func ParseDataText(text string) DataObject {
|
||||||
parseTag := func() (string, bool) {
|
parseTag := func() (string, bool) {
|
||||||
skipSpaces(true)
|
skipSpaces(true)
|
||||||
startPos := pos
|
startPos := pos
|
||||||
if data[pos] == '`' {
|
switch data[pos] {
|
||||||
|
case '`':
|
||||||
pos++
|
pos++
|
||||||
startPos++
|
startPos++
|
||||||
for data[pos] != '`' {
|
for data[pos] != '`' {
|
||||||
|
@ -398,8 +399,7 @@ func ParseDataText(text string) DataObject {
|
||||||
pos++
|
pos++
|
||||||
return str, true
|
return str, true
|
||||||
|
|
||||||
} else if data[pos] == '\'' || data[pos] == '"' {
|
case '\'', '"':
|
||||||
|
|
||||||
stopSymbol := data[pos]
|
stopSymbol := data[pos]
|
||||||
pos++
|
pos++
|
||||||
startPos++
|
startPos++
|
||||||
|
|
|
@ -147,7 +147,7 @@ func (picker *filePickerData) Files() []FileInfo {
|
||||||
func (picker *filePickerData) LoadFile(file FileInfo, result func(FileInfo, []byte)) {
|
func (picker *filePickerData) LoadFile(file FileInfo, result func(FileInfo, []byte)) {
|
||||||
if result != nil {
|
if result != nil {
|
||||||
for i, info := range picker.files {
|
for i, info := range picker.files {
|
||||||
if info.Name == file.Name && info.Size == file.Size && info.LastModified == file.LastModified {
|
if info.Name == file.Name && info.Size == file.Size && info.LastModified.Equal(file.LastModified) {
|
||||||
if info.data != nil {
|
if info.data != nil {
|
||||||
result(info, info.data)
|
result(info, info.data)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -746,10 +746,10 @@ func writePropertyValue(buffer *strings.Builder, tag PropertyName, value any, in
|
||||||
}
|
}
|
||||||
|
|
||||||
case float32:
|
case float32:
|
||||||
buffer.WriteString(fmt.Sprintf("%g", float64(value)))
|
fmt.Fprintf(buffer, "%g", float64(value))
|
||||||
|
|
||||||
case float64:
|
case float64:
|
||||||
buffer.WriteString(fmt.Sprintf("%g", value))
|
fmt.Fprintf(buffer, "%g", value)
|
||||||
|
|
||||||
case int:
|
case int:
|
||||||
if prop, ok := enumProperties[tag]; ok && value >= 0 && value < len(prop.values) {
|
if prop, ok := enumProperties[tag]; ok && value >= 0 && value < len(prop.values) {
|
||||||
|
|
|
@ -131,11 +131,12 @@ func (container *viewsContainerData) removeView(index int) View {
|
||||||
}
|
}
|
||||||
|
|
||||||
view := container.views[index]
|
view := container.views[index]
|
||||||
if index == 0 {
|
switch index {
|
||||||
|
case 0:
|
||||||
container.views = container.views[1:]
|
container.views = container.views[1:]
|
||||||
} else if index == count-1 {
|
case count - 1:
|
||||||
container.views = container.views[:index]
|
container.views = container.views[:index]
|
||||||
} else {
|
default:
|
||||||
container.views = append(container.views[:index], container.views[index+1:]...)
|
container.views = append(container.views[:index], container.views[index+1:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue