Skip to content

Commit

Permalink
remove division and re-multiplication for ptr_pairs index - count by …
Browse files Browse the repository at this point in the history
…2 instead
  • Loading branch information
bmaranville committed Aug 6, 2024
1 parent 03a729a commit 329ad17
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/hdf5_hl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ function process_data(data: Uint8Array, metadata: Metadata, json_compatible: boo
// Data buffer holds HDF5 `hvl_t` struct
// https://docs.hdfgroup.org/hdf5/v1_12/structhvl__t.html
const ptr_pairs = new Uint32Array(data.buffer); // both `size_t` length and pointer are 4-byte-long
const num_ptrs = ptr_pairs.length / 2;
const ptr_pairs_length = ptr_pairs.length;
const vlen_type = metadata.vlen_type as Metadata;
const { size } = vlen_type;

let output: (OutputData | JSONCompatibleOutputData)[] = [];
for (let p = 0; p < num_ptrs; p += 1) {
const length = ptr_pairs[p * 2]; // number of elements in this vlen array
const data_ptr = ptr_pairs[p * 2 + 1]; // pointer to this vlen array's data
for (let p = 0; p < ptr_pairs_length; p += 2) {
const length = ptr_pairs[p]; // number of elements in this vlen array
const data_ptr = ptr_pairs[p + 1]; // pointer to this vlen array's data

// Read vlen array data from memory
const data_nbytes = length * size;
Expand Down

0 comments on commit 329ad17

Please sign in to comment.