bugfixes and spelling fixes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 16 Feb 2023 14:31:04 +0000 (08:31 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 16 Feb 2023 14:31:04 +0000 (08:31 -0600)
core/container/map.onyx
core/container/set.onyx
core/onyx/cbindgen.onyx
core/random/random.onyx
core/runtime/info/foreign_blocks.onyx

index e1a20f8abea392d515b53be885b092af37c92079..2e84faf2e2ab8c8c84b5e1b1a420d303be98cd64 100644 (file)
@@ -330,7 +330,7 @@ as_iter :: (m: ^Map) =>
         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);
@@ -348,9 +348,9 @@ as_iter :: (m: ^Map) =>
         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;
         }
     }
 }
index 6d831c2a9c26d12721bde4307b4952f28fb62232..37939accfacc2b8d21735953cba3070b986525fb 100644 (file)
@@ -173,7 +173,7 @@ as_iter :: (s: ^Set) =>
         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);
@@ -191,9 +191,9 @@ as_iter :: (s: ^Set) =>
         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;
         }
     }
 }
index 2162896fbbac9afff5f654b9a90ed3083682f840..71ba0eae82ce64bb823979a9a3bbbe992cb2ca78 100644 (file)
@@ -197,14 +197,11 @@ compile_c_file :: (
         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, "), (");
index 20c7ccdd7435d7db70fcf3ad74fba14e3c116bdf..9553cb904f664a65b87293cf202b7309262d8dea 100644 (file)
@@ -11,7 +11,7 @@ Random :: struct {
     // 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 };
     }
 
@@ -106,5 +106,11 @@ string :: (bytes_long: u32, alpha_numeric := false, allocator := context.allocat
 #package {
     RANDOM_MULTIPLIER :: 25214903917
     RANDOM_INCREMENT  :: cast(i64) 11
+
+    #if #defined(core.os.time) {
+        __initial_value :: #(core.os.time())
+    } else {
+        __initial_value :: #(8675309)
+    }
 }
 
index e1f8f9793e1a7561a55b838589fb1ea36e70186d..d33de09381fd30cf217b83b10ce770c2dd403eb8 100644 (file)
@@ -4,7 +4,7 @@ package runtime.info
 //
 // 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.
 //
 
@@ -26,4 +26,4 @@ get_foreign_block :: (f: foreign_block) -> ^Foreign_Block {
     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
+}