Skip to content

Commit

Permalink
add getAlignKey and remove getAlign
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGraey committed Aug 28, 2019
1 parent e51181d commit f1df5d8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const KEY_SIGNED = 1 << 19;
const KEY_FLOAT = 1 << 20;
const KEY_NULLABLE = 1 << 21;
const KEY_MANAGED = 1 << 22;
const KEY_ALIGN_OFFSET = 14;
const VAL_ALIGN_OFFSET = 5;

// Array(BufferView) layout
Expand Down Expand Up @@ -129,14 +130,14 @@ function postInstantiate(baseModule, instance) {
return U32[(rttiBase + 4 >>> 2) + id * 2 + 1];
}

/** Gets the runtime alignment of a collection's values only. */
/** Gets the runtime alignment of a collection's values. */
function getAlignValue(info) {
return 31 - Math.clz32((info >>> VAL_ALIGN_OFFSET) & 31); // -1 if none
}

/** Gets the runtime alignment of a collection's values or keys. */
function getAlign(which, info) {
return 31 - Math.clz32((info / which) & 31); // -1 if none
/** Gets the runtime alignment of a collection's keys. */
function getAlignKey(info) {
return 31 - MAth.clz32((info >>> KEY_ALIGN_OFFSET) & 31); // -1 if none
}

function getTypedArray(Type, shift, arr) {
Expand Down

1 comment on commit f1df5d8

@jtenner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch out. MAth

Please sign in to comment.