@@ -39,7 +39,6 @@ type Tree struct {
39
39
40
40
s storer.EncodedObjectStorer
41
41
m map [string ]* TreeEntry
42
- t map [string ]* Tree // tree path cache
43
42
}
44
43
45
44
// GetTree gets a tree from an object storer and decodes it.
@@ -128,28 +127,10 @@ func (t *Tree) TreeEntryFile(e *TreeEntry) (*File, error) {
128
127
129
128
// FindEntry search a TreeEntry in this tree or any subtree.
130
129
func (t * Tree ) FindEntry (path string ) (* TreeEntry , error ) {
131
- if t .t == nil {
132
- t .t = make (map [string ]* Tree )
133
- }
134
-
135
130
pathParts := strings .Split (path , "/" )
136
131
startingTree := t
137
132
pathCurrent := ""
138
133
139
- // search for the longest path in the tree path cache
140
- for i := len (pathParts ) - 1 ; i > 1 ; i -- {
141
- path := filepath .Join (pathParts [:i ]... )
142
-
143
- tree , ok := t .t [path ]
144
- if ok {
145
- startingTree = tree
146
- pathParts = pathParts [i :]
147
- pathCurrent = path
148
-
149
- break
150
- }
151
- }
152
-
153
134
var tree * Tree
154
135
var err error
155
136
for tree = startingTree ; len (pathParts ) > 1 ; pathParts = pathParts [1 :] {
@@ -158,7 +139,6 @@ func (t *Tree) FindEntry(path string) (*TreeEntry, error) {
158
139
}
159
140
160
141
pathCurrent = filepath .Join (pathCurrent , pathParts [0 ])
161
- t .t [pathCurrent ] = tree
162
142
}
163
143
164
144
return tree .entry (pathParts [0 ])
@@ -182,10 +162,6 @@ func (t *Tree) dir(baseName string) (*Tree, error) {
182
162
}
183
163
184
164
func (t * Tree ) entry (baseName string ) (* TreeEntry , error ) {
185
- if t .m == nil {
186
- t .buildMap ()
187
- }
188
-
189
165
entry , ok := t .m [baseName ]
190
166
if ! ok {
191
167
return nil , ErrEntryNotFound
@@ -269,6 +245,8 @@ func (t *Tree) Decode(o plumbing.EncodedObject) (err error) {
269
245
})
270
246
}
271
247
248
+ t .buildMap ()
249
+
272
250
return nil
273
251
}
274
252
0 commit comments