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
1622 if (n <= 0)1622 if (n <= 0)
1623 break;1623 break;
1624 for (i = 0; i < n; i++)1624 for (i = 0; i < n; i++)
1625 hash = hash * 1099511628211ull + temp[i]; // FNV_prime1625 hash = hash * 1099511628211ull ^ temp[i]; // FNV_prime
1626 }1626 }
1627 fclose(fp);1627 fclose(fp);
1628 if (hash == 0)1628 return hash ? hash : 1ull;
1629 hash = 1;
1630 return hash;
1631}1629}
1632#endif1630#endif
1633 1631
@@ -1658,10 +1656,14 @@ static CachedInclude *search_cached_include(TCCState *s1, const char *filename, · 24 unmodified lines
1658 break;1656 break;
1659 e = s1->cached_includes[i - 1];1657 e = s1->cached_includes[i - 1];
1660 if (e->st.st_size == st.st_size) {1658 if (e->st.st_size == st.st_size) {
1659 if (0 == PATHCMP(e->filename, filename)) {
1660 hash = e->hash;
1661 break;
1662 }
1661 if (e->hash == 0)1663 if (e->hash == 0)
1662 e->hash = calc_file_hash(e->filename);1664 e->hash = calc_file_hash(e->filename);
1663 hash = calc_file_hash(filename);1665 if (hash == 0)
1664 break;1666 hash = calc_file_hash(filename);
1665 }1667 }
1666 i = e->hash_next;1668 i = e->hash_next;
1667 }1669 }

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