Skip to content

RFC: Return preallocated error for DCM_ERROR_CODE_MISSING_FRAME#116

Open
bgilbert wants to merge 1 commit into
ImagingDataCommons:mainfrom
bgilbert:prealloc
Open

RFC: Return preallocated error for DCM_ERROR_CODE_MISSING_FRAME#116
bgilbert wants to merge 1 commit into
ImagingDataCommons:mainfrom
bgilbert:prealloc

Conversation

@bgilbert
Copy link
Copy Markdown
Collaborator

@bgilbert bgilbert commented Jun 2, 2026

DCM_ERROR_CODE_MISSING_FRAME is unusual: it's returned by one function, which might be called in a tight loop by an application checking which frames are available in a DcmFilehandle. As such, we don't want to incur allocation and string-formatting overhead each time a frame is missing. Return a generic preallocated DcmError instead, and special-case dcm_error_free() so we don't free it.

Pursuant to #115 (comment). I'm still not sure how I feel about this solution.

slidetool slide open 3DHISTECH-2/2 with the current state of openslide/openslide#648:

Before:
real	0m0.148s
user	0m0.140s
sys	0m0.008s

After:
real	0m0.066s
user	0m0.062s
sys	0m0.004s

DCM_ERROR_CODE_MISSING_FRAME is unusual: it's returned by one function,
which might be called in a tight loop by an application checking which
frames are available in a DcmFilehandle.  As such, we don't want to incur
allocation and string-formatting overhead each time a frame is missing.
Return a generic preallocated DcmError instead, and ensure
dcm_error_free() doesn't free it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant