Skip to content

Commit aa0b0db

Browse files
authored
Merge pull request #1709 from gsjaardema/patch-39
Proof-of-Concept: Avoid N^2 behavior in NC4_inq_dim
2 parents 9393fd6 + 3e919a5 commit aa0b0db

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

libhdf5/hdf5dim.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,16 @@ NC4_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
166166
of records from all the vars that share this
167167
dimension. */
168168
*lenp = 0;
169-
if ((ret = nc4_find_dim_len(dim_grp, dimid, &lenp)))
170-
return ret;
169+
if (dim->len == 0) {
170+
if ((ret = nc4_find_dim_len(dim_grp, dimid, &lenp)))
171+
return ret;
172+
if (h5->no_write == NC_TRUE) {
173+
dim->len = *lenp;
174+
}
175+
}
176+
else {
177+
*lenp = dim->len;
178+
}
171179
}
172180
else
173181
{

0 commit comments

Comments
 (0)