some optimizations

This commit is contained in:
lion 2025-09-09 22:34:13 +08:00
parent f0a9462041
commit 87d53b5018
3 changed files with 4 additions and 4 deletions

View File

@ -152,7 +152,7 @@ func (e *Editor) PutSegment(seg *Segment) (int, int, error) {
found = true
}
if found == false {
if !found {
continue
}
@ -259,7 +259,7 @@ func (e *Editor) PutFile(src string) (int, int, error) {
func (e *Editor) Save() error {
// check the to-save flag
if e.toSave == false {
if !e.toSave {
return fmt.Errorf("nothing changed")
}

View File

@ -161,7 +161,7 @@ func TestIterateSegments(t *testing.T) {
t.Fatalf("failed to open tests file: %s", err)
}
err = IterateSegments(handle, func(l string) {
_ = IterateSegments(handle, func(l string) {
// fmt.Printf("load segment: `%s`\n", l)
}, func(seg *Segment) error {
fmt.Printf("get segment: `%s`\n", seg)

View File

@ -29,7 +29,7 @@ type Version struct {
}
func (v *Version) String() string {
return fmt.Sprintf("{Id:%d, Name:%d, Bytes:%d, IndexSize: %d}", v.Id, v.Name, v.Bytes, v.SegmentIndexSize)
return fmt.Sprintf("{Id:%d, Name:%s, Bytes:%d, IndexSize: %d}", v.Id, v.Name, v.Bytes, v.SegmentIndexSize)
}
var (