return lr;
}
- full :: (use map: ^Map) => entries.count >= (hashes.count * 3) / 4;
+ full :: (use map: ^Map) => entries.count >= (hashes.count >> 2) * 3;
grow :: (use map: ^Map) {
new_size := math.max(hashes.count << 1, 8);
for ^entry: entries {
defer index += 1;
- lr := lookup(map, entry.key);
- entries[index].next = hashes[lr.hash_index];
- hashes[lr.hash_index] = index;
+ hash_index := entry.hash % hashes.count;
+ entries[index].next = hashes[hash_index];
+ hashes[hash_index] = index;
}
}
}
return lr;
}
- full :: (use set: ^Set) => entries.count >= ~~(0.75f * ~~hashes.count);
+ full :: (use set: ^Set) => entries.count >= (hashes.count >> 2) * 3;
grow :: (use set: ^Set) {
new_size := math.max(hashes.count << 1, 8);
for ^entry: entries {
defer index += 1;
- lr := lookup(set, entry.value);
- entries[index].next = hashes[lr.hash_index];
- hashes[lr.hash_index] = index;
+ hash_index := entry.hash % hashes.count;
+ entries[index].next = hashes[hash_index];
+ hashes[hash_index] = index;
}
}
}
assert(method_info.kind == .Function, "Expected function type.");
io.write_format(writer, "ONYX_DEF({}, (", ff.name);
- i := 0;
+
for method_info.parameter_types {
- io.write(writer, type_encoding(it));
+ if !#first do io.write(writer, ", ");
- if i != method_info.parameter_types.count - 1 {
- io.write(writer, ", ");
- }
- i += 1;
+ io.write(writer, type_encoding(it));
}
io.write(writer, "), (");
// Creates a new random number generator.
// An initial seed can be passed in, otherwise the
// current UNIX time is used.
- make :: (seed: i64 = core.os.time()) -> Random {
+ make :: (seed: i64 = (#unquote __initial_value)) -> Random {
return .{ seed };
}
#package {
RANDOM_MULTIPLIER :: 25214903917
RANDOM_INCREMENT :: cast(i64) 11
+
+ #if #defined(core.os.time) {
+ __initial_value :: #(core.os.time())
+ } else {
+ __initial_value :: #(8675309)
+ }
}
//
// Foreign Blocks
// Because foreign blocks can generate a lot of data, and their data is only
-// really helpful in a handful of cases, you need to pass "--generate-foreign-bindings"
+// really helpful in a handful of cases, you need to pass "--generate-foreign-info"
// to have these arrays filled out.
//
if ~~f < cast(i32) 0 || ~~f >= cast(i32) foreign_blocks.count do return null;
return foreign_blocks[cast(i32) f];
-}
\ No newline at end of file
+}