mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-16 16:31:32 +00:00
if that's what's necessary
This commit is contained in:
@ -4,11 +4,16 @@ import { HASH } from "./util/hash";
|
||||
// A deterministic hash set based on CloseTable from https://github.com/jorendorff/dht
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@inline const INITIAL_CAPACITY = 4;
|
||||
@inline
|
||||
const INITIAL_CAPACITY = 4;
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@inline const FILL_FACTOR: f64 = 8 / 3;
|
||||
@inline
|
||||
const FILL_FACTOR: f64 = 8 / 3;
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@inline const FREE_FACTOR: f64 = 3 / 4;
|
||||
@inline
|
||||
const FREE_FACTOR: f64 = 3 / 4;
|
||||
|
||||
/** Structure of a set entry. */
|
||||
@unmanaged class SetEntry<K> {
|
||||
@ -18,15 +23,18 @@ import { HASH } from "./util/hash";
|
||||
|
||||
/** Empty bit. */
|
||||
// @ts-ignore: decorator
|
||||
@inline const EMPTY: usize = 1 << 0;
|
||||
@inline
|
||||
const EMPTY: usize = 1 << 0;
|
||||
|
||||
/** Size of a bucket. */
|
||||
// @ts-ignore: decorator
|
||||
@inline const BUCKET_SIZE = sizeof<usize>();
|
||||
@inline
|
||||
const BUCKET_SIZE = sizeof<usize>();
|
||||
|
||||
/** Computes the alignment of an entry. */
|
||||
// @ts-ignore: decorator
|
||||
@inline function ENTRY_ALIGN<K>(): usize {
|
||||
@inline
|
||||
function ENTRY_ALIGN<K>(): usize {
|
||||
// can align to 4 instead of 8 if 32-bit and K is <= 32-bits
|
||||
const align = (sizeof<K>() > sizeof<usize>() ? sizeof<K>() : sizeof<usize>()) - 1;
|
||||
return align;
|
||||
@ -34,7 +42,8 @@ import { HASH } from "./util/hash";
|
||||
|
||||
/** Computes the aligned size of an entry. */
|
||||
// @ts-ignore: decorator
|
||||
@inline function ENTRY_SIZE<K>(): usize {
|
||||
@inline
|
||||
function ENTRY_SIZE<K>(): usize {
|
||||
const align = ENTRY_ALIGN<K>();
|
||||
const size = (offsetof<SetEntry<K>>() + align) & ~align;
|
||||
return size;
|
||||
|
Reference in New Issue
Block a user