8000 Fix library-cache-miss regression by cmaglie · Pull Request #433 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

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 1 commit
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
Prev Previous commit
Changed 'includeCacheEntry' field to pointer type
This allows a better memory management and avoids struct copy
operations.
  • Loading branch information
cmaglie committed Oct 1, 2019
commit 5f7b54a14051af5f21c0f85b862c9a9d9cc10590
10 changes: 5 additions & 5 deletions legacy/builder/container_find_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ type includeCacheEntry struct {
Includepath *paths.Path
}

func (entry includeCacheEntry) String() string {
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 {
func (entry *includeCacheEntry) Equals(other *includeCacheEntry) bool {
return entry.String() == other.String()
}

Expand All @@ -212,13 +212,13 @@ type includeCache struct {
// Index into entries of the next entry to be processed. Unused
// when the cache is invalid.
next int
entries []includeCacheEntry // XXX: Convert to pointers
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 @@ -237,7 +237,7 @@ 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().Equals(entry) {
cache.next++
Expand Down
0