[MOAB-dev] r4608 - MOAB/trunk/test/h5file
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Thu Mar 17 17:17:01 CDT 2011
Author: kraftche
Date: 2011-03-17 17:17:01 -0500 (Thu, 17 Mar 2011)
New Revision: 4608
Modified:
MOAB/trunk/test/h5file/validate.c
Log:
bug fix and small performance improvement for h5m validate tool
Modified: MOAB/trunk/test/h5file/validate.c
===================================================================
--- MOAB/trunk/test/h5file/validate.c 2011-03-17 21:45:16 UTC (rev 4607)
+++ MOAB/trunk/test/h5file/validate.c 2011-03-17 22:17:01 UTC (rev 4608)
@@ -63,8 +63,9 @@
file IDs for entities with a specific dimension. */
static long* get_dim_ranges( struct mhdf_FileDesc* desc, int dim, int* num_ranges_out );
+/* Merge adjacent ranges */
+static int merge_ranges( long* ranges, int nranges );
-
/* Misc. high-level helper routines */
/* Check that end-index lists used in various file data for variable-length data
@@ -116,7 +117,7 @@
{
long l1 = *(const long*)p1;
long l2 = *(const long*)p2;
- return (l1 - l2)/labs(l1 - l2);
+ return l1 < l2 ? -1 : l1 > l2 ? 1 : 0;
}
/* Compare start_ids of mhdf_EntDesc pointed to by passed values */
@@ -355,6 +356,8 @@
ranges[j++] = desc->elems[i].desc.start_id;
ranges[j++] = desc->elems[i].desc.count;
}
+
+ *num_ranges_out = merge_ranges( ranges, *num_ranges_out );
return ranges;
}
@@ -797,6 +800,30 @@
return 0;
}
+static int merge_ranges( long* ranges, int nranges )
+{
+ long i, n;
+
+ if (nranges < 1)
+ return 0;
+
+ /* merge adjacent */
+ qsort( ranges, nranges, 2*sizeof(long), &lcomp );
+ n = 1;
+ for (i = 1; i < nranges; ++i) {
+ if (ranges[2*n-2] + ranges[2*n-1+1] == ranges[2*i]) {
+ ranges[2*n-1] += ranges[2*i+1];
+ }
More information about the moab-dev
mailing list