aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/image-hdf5.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-01 16:35:22 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:44 +0200
commit2e6c22d51ce130180f9d6e13f894c86fe3027e2e (patch)
tree58af77403e00ba6444066d3afbfda03555f1c7f4 /libcrystfel/src/image-hdf5.c
parent6e1a971e9d0ed372a2c6066d84b90f4a61ee88b5 (diff)
Avoid event enumeration if only one event is possible
The enumeration works in this case, of course, but is a waste of a not insignificant amount of time.
Diffstat (limited to 'libcrystfel/src/image-hdf5.c')
-rw-r--r--libcrystfel/src/image-hdf5.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c
index 3e2b17fb..26caa13a 100644
--- a/libcrystfel/src/image-hdf5.c
+++ b/libcrystfel/src/image-hdf5.c
@@ -1498,6 +1498,21 @@ char **image_hdf5_expand_frames(const DataTemplate *dtempl,
int dims_expected;
struct ev_list full_evs;
+ full_evs.events = NULL;
+ full_evs.n_events = 0;
+ full_evs.max_events = 0;
+
+ /* If the DataTemplate already says that one frame will be
+ * found per file, short-circuit this whole affair */
+ if ( (num_placeholders(&dtempl->panels[0]) == 0)
+ && (num_path_placeholders(dtempl->panels[0].data) == 0) )
+ {
+ add_to_list(&full_evs, "//");
+ *pn_frames = full_evs.n_events;
+ return full_evs.events;
+ }
+
+
fh = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT);
if ( fh < 0 ) {
ERROR("Couldn't open file '%s'\n", filename);
@@ -1521,10 +1536,6 @@ char **image_hdf5_expand_frames(const DataTemplate *dtempl,
dims_expected = n_dims_expected(&dtempl->panels[0]);
- full_evs.events = NULL;
- full_evs.n_events = 0;
- full_evs.max_events = 0;
-
/* For each expanded path, enumerate the placeholder
* dimensions. Once again, since the number of placeholders
* must be the same for each panel, and the substituted values