aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/ocda_functions.org
diff options
context:
space:
mode:
Diffstat (limited to 'org/ocda_functions.org')
-rw-r--r--org/ocda_functions.org12
1 files changed, 11 insertions, 1 deletions
diff --git a/org/ocda_functions.org b/org/ocda_functions.org
index 71d1b97..0e42cfb 100644
--- a/org/ocda_functions.org
+++ b/org/ocda_functions.org
@@ -3430,7 +3430,16 @@ SHA_256_Hashes_ obj_digest(M)(
M manifested,
) {
ST_file_name_hash_size_ safeComputeHashAndSize(N,P)(N filename, P file_path) @trusted {
- auto file_with_path = file_path ~ filename;
+ string file_with_path = (file_path ~ filename).to!string;
+ /+ ↓ read & hash each image file once: an image referenced from several
+ objects (or from several documents sharing an image directory) was
+ otherwise re-read and re-hashed for every reference. static is
+ thread-local in D, so the cache needs no synchronisation
+ +/
+ static ST_file_name_hash_size_[string] _image_file_info_cache;
+ if (auto _cached = file_with_path in _image_file_info_cache) {
+ return *_cached;
+ }
ST_file_name_hash_size_ _file_info;
_file_info.fileName = filename;
/+ ↓ a referenced image that is absent or unreadable is recorded as
@@ -3466,6 +3475,7 @@ SHA_256_Hashes_ obj_digest(M)(
}
}
}
+ _image_file_info_cache[file_with_path] = _file_info;
return _file_info;
}
obj.metainfo.sha256.text = obj.text.sha256Of;