Skip to content

Fix library-cache-miss regression #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions legacy/builder/container_find_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ package builder

import (
"encoding/json"
"fmt"
"os"
"os/exec"
"time"
Expand Down Expand Up @@ -196,19 +197,28 @@ type includeCacheEntry struct {
Includepath *paths.Path
}

func (entry *includeCacheEntry) String() string {
return fmt.Sprintf("SourceFile: %s; Include: %s; IncludePath: %s",
entry.Sourcefile, entry.Include, entry.Includepath)
}

func (entry *includeCacheEntry) Equals(other *includeCacheEntry) bool {
return entry.String() == other.String()
}

type includeCache struct {
// Are the cache contents valid so far?
valid bool
// Index into entries of the next entry to be processed. Unused
// when the cache is invalid.
next int
entries []includeCacheEntry
entries []*includeCacheEntry
}

// Return the next cache entry. Should only be called when the cache is
// valid and a next entry is available (the latter can be checked with
// ExpectFile). Does not advance the cache.
func (cache *includeCache) Next() includeCacheEntry {
func (cache *includeCache) Next() *includeCacheEntry {
return cache.entries[cache.next]
}

Expand All @@ -227,9 +237,9 @@ func (cache *includeCache) ExpectFile(sourcefile *paths.Path) {
// invalidated, or was already invalid, an entry with the given values
// is appended.
func (cache *includeCache) ExpectEntry(sourcefile *paths.Path, include string, librarypath *paths.Path) {
entry := includeCacheEntry{Sourcefile: sourcefile, Include: include, Includepath: librarypath}
entry := &includeCacheEntry{Sourcefile: sourcefile, Include: include, Includepath: librarypath}
if cache.valid {
if cache.next < len(cache.entries) && cache.Next() == entry {
if cache.next < len(cache.entries) && cache.Next().Equals(entry) {
cache.next++
} else {
cache.valid = false
Expand Down