style: 去除部分无用字段,优化整体可读性
This commit is contained in:
@@ -146,7 +146,7 @@ func (slf *Map[Key, Value]) rangeFree(handle func(key Key, value Value, skip fun
|
||||
|
||||
func (slf *Map[Key, Value]) Keys() []Key {
|
||||
var s = make([]Key, 0, len(slf.data))
|
||||
for k, _ := range slf.data {
|
||||
for k := range slf.data {
|
||||
s = append(s, k)
|
||||
}
|
||||
return s
|
||||
|
||||
+3
-3
@@ -102,10 +102,10 @@ func LineCount(filePath string) int {
|
||||
return line
|
||||
}
|
||||
|
||||
// FilePaths 获取指定目录下的所有文件路径
|
||||
// Paths 获取指定目录下的所有文件路径
|
||||
// - 包括了子目录下的文件
|
||||
// - 不包含目录
|
||||
func FilePaths(dir string) []string {
|
||||
func Paths(dir string) []string {
|
||||
var paths []string
|
||||
abs, err := filepath.Abs(dir)
|
||||
if err != nil {
|
||||
@@ -119,7 +119,7 @@ func FilePaths(dir string) []string {
|
||||
for _, file := range files {
|
||||
fileAbs := filepath.Join(abs, file.Name())
|
||||
if file.IsDir() {
|
||||
paths = append(paths, FilePaths(fileAbs)...)
|
||||
paths = append(paths, Paths(fileAbs)...)
|
||||
continue
|
||||
}
|
||||
paths = append(paths, fileAbs)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func TestFilePaths(t *testing.T) {
|
||||
var line int
|
||||
var fileCount int
|
||||
for _, path := range file.FilePaths(`D:\sources\minotaur`) {
|
||||
for _, path := range file.Paths(`D:\sources\minotaur`) {
|
||||
if !strings.HasSuffix(path, ".go") {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func ExampleNavMesh_FindPath() {
|
||||
|
||||
for x := sx; x <= bx; x++ {
|
||||
for y := sy; y <= by; y++ {
|
||||
fp.Put(geometry.NewPoint[int](int(x), int(y)), '+')
|
||||
fp.Put(geometry.NewPoint[int](x, y), '+')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func (slf *SortMap[K, V]) For(handle func(key K, value V) bool) {
|
||||
|
||||
func (slf *SortMap[K, V]) ForSort(handle func(key K, value V) bool) {
|
||||
var indexes []int
|
||||
for i, _ := range slf.s {
|
||||
for i := range slf.s {
|
||||
indexes = append(indexes, i)
|
||||
}
|
||||
sort.Ints(indexes)
|
||||
@@ -85,7 +85,7 @@ func (slf *SortMap[K, V]) ToSlice() []V {
|
||||
|
||||
func (slf *SortMap[K, V]) ToSliceSort() []V {
|
||||
var indexes []int
|
||||
for i, _ := range slf.s {
|
||||
for i := range slf.s {
|
||||
indexes = append(indexes, i)
|
||||
}
|
||||
sort.Ints(indexes)
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ func Pow(a, n int) int {
|
||||
if n == 1 {
|
||||
return a
|
||||
}
|
||||
var result int = 1
|
||||
var result = 1
|
||||
factor := a
|
||||
for n != 0 {
|
||||
if n&1 != 0 {
|
||||
|
||||
@@ -216,7 +216,7 @@ func (slf *Map[Key, Value]) Keys() []Key {
|
||||
defer slf.lock.RUnlock()
|
||||
}
|
||||
var s = make([]Key, 0, len(slf.data))
|
||||
for k, _ := range slf.data {
|
||||
for k := range slf.data {
|
||||
s = append(s, k)
|
||||
}
|
||||
return s
|
||||
|
||||
@@ -183,7 +183,7 @@ func (slf *MapSegment[Key, Value]) RangeFree(handle func(key Key, value Value, s
|
||||
func (slf *MapSegment[Key, Value]) Keys() []Key {
|
||||
var s = make([]Key, 0, len(slf.cache))
|
||||
slf.lock.RLock()
|
||||
for k, _ := range slf.cache {
|
||||
for k := range slf.cache {
|
||||
s = append(s, k)
|
||||
}
|
||||
defer slf.lock.RUnlock()
|
||||
|
||||
Reference in New Issue
Block a user