@@ -108,6 +108,7 @@ package builder
108
108
109
109
import (
110
110
"encoding/json"
111
+ "fmt"
111
112
"os"
112
113
"os/exec"
113
114
"time"
@@ -196,19 +197,28 @@ type includeCacheEntry struct {
196
197
Includepath * paths.Path
197
198
}
198
199
200
+ func (entry * includeCacheEntry ) String () string {
201
+ return fmt .Sprintf ("SourceFile: %s; Include: %s; IncludePath: %s" ,
202
+ entry .Sourcefile , entry .Include , entry .Includepath )
203
+ }
204
+
205
+ func (entry * includeCacheEntry ) Equals (other * includeCacheEntry ) bool {
206
+ return entry .String () == other .String ()
207
+ }
208
+
199
209
type includeCache struct {
200
210
// Are the cache contents valid so far?
201
211
valid bool
202
212
// Index into entries of the next entry to be processed. Unused
203
213
// when the cache is invalid.
204
214
next int
205
- entries []includeCacheEntry
215
+ entries []* includeCacheEntry
206
216
}
207
217
208
218
// Return the next cache entry. Should only be called when the cache is
209
219
// valid and a next entry is available (the latter can be checked with
210
220
// ExpectFile). Does not advance the cache.
211
- func (cache * includeCache ) Next () includeCacheEntry {
221
+ func (cache * includeCache ) Next () * includeCacheEntry {
212
222
return cache .entries [cache .next ]
213
223
}
214
224
@@ -227,9 +237,9 @@ func (cache *includeCache) ExpectFile(sourcefile *paths.Path) {
227
237
// invalidated, or was already invalid, an entry with the given values
228
238
// is appended.
229
239
func (cache * includeCache ) ExpectEntry (sourcefile * paths.Path , include string , librarypath * paths.Path ) {
230
- entry := includeCacheEntry {Sourcefile : sourcefile , Include : include , Includepath : librarypath }
240
+ entry := & includeCacheEntry {Sourcefile : sourcefile , Include : include , Includepath : librarypath }
231
241
if cache .valid {
232
- if cache .next < len (cache .entries ) && cache .Next () == entry {
242
+ if cache .next < len (cache .entries ) && cache .Next (). Equals ( entry ) {
233
243
cache .next ++
234
244
} else {
235
245
cache .valid = false
0 commit comments