History

Small update on pragma once

Update on calc_file_hash. Use xor instead of +. Only calculate has if file name differs in search_cached_include.

herman ten brugge committed 3 years ago

Commit 4e363a11 parent 30fd24a1 file · +8 −6Browse files

Unified · Split

tccpp.c+8−6
@@ -1622,12 +1622,10 @@ static unsigned long long calc_file_hash(const char *filename) · 1621 unmodified lines
16221622 if (n <= 0)
16231623 break;
16241624 for (i = 0; i < n; i++)
1625− hash = hash * 1099511628211ull + temp[i]; // FNV_prime
1625+ hash = hash * 1099511628211ull ^ temp[i]; // FNV_prime
16261626 }
16271627 fclose(fp);
1628− if (hash == 0)
1629− hash = 1;
1630− return hash;
1628+ return hash ? hash : 1ull;
16311629 }
16321630 #endif
16331631
@@ -1658,10 +1656,14 @@ static CachedInclude *search_cached_include(TCCState *s1, const char *filename, · 24 unmodified lines
16581656 break;
16591657 e = s1->cached_includes[i - 1];
16601658 if (e->st.st_size == st.st_size) {
1659+ if (0 == PATHCMP(e->filename, filename)) {
1660+ hash = e->hash;
1661+ break;
1662+ }
16611663 if (e->hash == 0)
16621664 e->hash = calc_file_hash(e->filename);
1663− hash = calc_file_hash(filename);
1664− break;
1665+ if (hash == 0)
1666+ hash = calc_file_hash(filename);
16651667 }
16661668 i = e->hash_next;
16671669 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t