Menu ▾ ▴

#199 Use constant tables for metadata tag lookup

open
nobody
None
5
2026-11-06
2026-11-06
No

FreeImage builds metadata lookup maps on the heap during initialization even though the tag definitions are static. Replace those maps with sorted constant descriptor arrays and binary search. In the tested x86-64 build of current upstream tables, this removes 1,349 allocation calls and 64,752 retained requested bytes per initialized library instance.

Preserve all tables, tag IDs, names and descriptions, including the empty Apple iOS model. Reverse lookup retains the lowest-ID result for duplicate names. Public model mappings, unknown-tag fallback behavior and stable string lifetimes are unchanged. The public FreeImage C API is unchanged.

The patch targets official SVN trunk r1911 and adds a standalone C++98 metadata regression. Optimized and ASan/UBSan/LeakSanitizer differential checks cover 1,638,400 model/ID pairs. GCC/Clang checks, the full Linux library build and upstream TestAPI pass. TestAPI uses a separate link of the existing tif_hash_set.c omitted from Makefile.srcs; that pre-existing build workaround is not included in this patch.

1 Attachments

Discussion

Anonymous
Anonymous

Add attachments
Cancel