// Hash a file ignoring comments. Returns a bitmask of HASH_SOURCE_CODE_*
// results.
int
-hash_source_code_file(const Config& config, struct hash* hash, const char* path)
+hash_source_code_file(const Config& config,
+ struct hash* hash,
+ const char* path,
+ size_t size_hint)
{
if (is_precompiled_header(path)) {
if (hash_file(hash, path)) {
} else {
char* data;
size_t size;
- if (!read_file(path, 0, &data, &size)) {
+ if (!read_file(path, size_hint, &data, &size)) {
return HASH_SOURCE_CODE_ERROR;
}
int result = hash_source_code_string(config, hash, data, size, path);
const char* path);
int hash_source_code_file(const Config& config,
struct hash* hash,
- const char* path);
+ const char* path,
+ size_t size_hint = 0);
bool hash_command_output(struct hash* hash,
const char* command,
const char* compiler);
auto hashed_files_iter = hashed_files.find(path);
if (hashed_files_iter == hashed_files.end()) {
struct hash* hash = hash_init();
- int ret = hash_source_code_file(ctx.config, hash, path.c_str());
+ int ret = hash_source_code_file(ctx.config, hash, path.c_str(), fs.size);
if (ret & HASH_SOURCE_CODE_ERROR) {
cc_log("Failed hashing %s", path.c_str());
hash_free(hash);