Remove some deprecated use.

This commit is contained in:
Christoffer Lerno
2025-03-01 23:58:28 +01:00
parent f52c2a6f96
commit 55c88408be
19 changed files with 68 additions and 68 deletions

View File

@@ -26,7 +26,7 @@ struct MapImpl
@require load_factor > 0.0 "The load factor must be higher than 0"
@require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
*>
fn Map new(uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap()) @deprecated("Map is deprecated")
fn Map new(uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator allocator = allocator::heap())
{
MapImpl* map = allocator::alloc(allocator, MapImpl);
_init(map, capacity, load_factor, allocator);

View File

@@ -38,17 +38,17 @@ struct PrivatePriorityQueue (Printable)
fn void PrivatePriorityQueue.init(&self, Allocator allocator, usz initial_capacity = 16, ) @inline
{
self.heap.new_init(initial_capacity, allocator);
self.heap.init(allocator, initial_capacity);
}
fn void PrivatePriorityQueue.new_init(&self, usz initial_capacity = 16, Allocator allocator = allocator::heap()) @inline
{
self.heap.new_init(initial_capacity, allocator);
self.heap.init(allocator, initial_capacity);
}
fn void PrivatePriorityQueue.temp_init(&self, usz initial_capacity = 16) @inline
{
self.heap.new_init(initial_capacity, allocator::temp()) @inline;
self.heap.init(allocator::temp(), initial_capacity) @inline;
}

View File

@@ -24,7 +24,7 @@ fn void set_get()
assert(bs.cardinality() == 2);
List found;
found.temp_init();
found.tinit();
foreach (i, x : bs)
{
switch (i)
@@ -50,7 +50,7 @@ def GrowableBitSet = GrowableBitSet(<char>);
fn void growable_set_get()
{
GrowableBitSet bs;
bs.temp_init();
bs.tinit();
assert(bs.cardinality() == 0, "Invalid cardinality");
assert(!bs.get(0), "Get was true");
@@ -68,7 +68,7 @@ fn void growable_set_get()
assert(bs.len() == 2001, "Len should be 2001");
List found;
found.temp_init();
found.tinit();
foreach (i, x : bs)
{
switch (i)

View File

@@ -43,7 +43,7 @@ fn void copy_keys() @test
@pool()
{
IntMap x;
x.temp_init();
x.tinit();
x.set("hello", 0); // keys copied into temp hashmap
y = x.copy_keys(allocator::heap()); // keys copied out
// end of pool: hashmap and its copied-in keys dropped

View File

@@ -105,7 +105,7 @@ fn void init_with_array()
{
IntList foo;
defer foo.free();
foo.new_init_with_array({ 1, 2, 3});
foo.init_with_array(mem, { 1, 2, 3});
assert(foo.len() == 3);
assert(foo[2] == 3);
}
@@ -113,7 +113,7 @@ fn void init_with_array()
fn void init_with_temp_array()
{
IntList foo;
foo.temp_init_with_array({ 1, 2, 3});
foo.tinit_with_array({ 1, 2, 3});
assert(foo.len() == 3);
assert(foo[2] == 3);
}

View File

@@ -18,7 +18,7 @@ fn void map()
{
TestHashMap m;
assert(!m.is_initialized());
m.temp_init();
m.tinit();
assert(m.is_initialized());
assert(m.is_empty());
assert(m.len() == 0);
@@ -42,7 +42,7 @@ fn void map()
}
List list;
list.temp_init();
list.tinit();
m.@each(;String key, usz value)
{
list.push({key, value});
@@ -83,7 +83,7 @@ fn void map_remove()
{
TestHashMap m;
assert(!@ok(m.remove("A")));
m.temp_init();
m.tinit();
assert(!@ok(m.remove("A")));
m.set("A", 0);
assert(@ok(m.remove("A")));
@@ -92,14 +92,14 @@ fn void map_remove()
fn void map_copy()
{
TestHashMap hash_map;
hash_map.temp_init();
hash_map.tinit();
hash_map.set("aa", 1);
hash_map.set("b", 2);
hash_map.set("bb", 1);
TestHashMap hash_map_copy;
hash_map_copy.temp_init_from_map(&hash_map);
hash_map_copy.tinit_from_map(&hash_map);
assert(hash_map_copy.len() == hash_map.len());

View File

@@ -3,7 +3,7 @@ import std::io;
fn void test_write_0b1() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -16,7 +16,7 @@ fn void test_write_0b1() {
fn void test_write_0b1111() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -29,7 +29,7 @@ fn void test_write_0b1111() {
fn void test_write_0b1111_1111() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -42,7 +42,7 @@ fn void test_write_0b1111_1111() {
fn void test_write_0b1000() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -55,7 +55,7 @@ fn void test_write_0b1000() {
fn void test_write_0b01000() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -68,7 +68,7 @@ fn void test_write_0b01000() {
fn void test_write_0b0001() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -82,7 +82,7 @@ fn void test_write_0b0001() {
fn void test_write_0b0000_0001() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -95,7 +95,7 @@ fn void test_write_0b0000_0001() {
fn void test_write_10_bits() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -109,7 +109,7 @@ fn void test_write_10_bits() {
fn void test_write_16_bits() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -122,7 +122,7 @@ fn void test_write_16_bits() {
fn void test_write_24_bits() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -135,7 +135,7 @@ fn void test_write_24_bits() {
fn void test_write_30_bits() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -148,7 +148,7 @@ fn void test_write_30_bits() {
fn void test_write_32_bits() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -161,7 +161,7 @@ fn void test_write_32_bits() {
fn void test_write_2_bits_multiple() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -176,7 +176,7 @@ fn void test_write_2_bits_multiple() {
fn void test_write_10_bits_multiple() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -192,7 +192,7 @@ fn void test_write_10_bits_multiple() {
fn void test_write_24_bits_multiple() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -206,7 +206,7 @@ fn void test_write_24_bits_multiple() {
fn void test_write_30_bits_multiple() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -220,7 +220,7 @@ fn void test_write_30_bits_multiple() {
fn void test_write_32_bits_multiple() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);
@@ -234,7 +234,7 @@ fn void test_write_32_bits_multiple() {
fn void test_write_mixed_multiple() {
ByteWriter w;
w.temp_init();
w.tinit();
BitWriter bw;
bw.init(&w);

View File

@@ -27,7 +27,7 @@ fn void readbuffer()
reader_buf.init(&src, buf[..]);
ByteWriter bw;
bw.temp_init();
bw.tinit();
usz n = io::copy_to(&reader_buf, &bw)!!;
@@ -39,7 +39,7 @@ fn void readbuffer()
fn void writebuffer_large()
{
ByteWriter out;
out.temp_init();
out.tinit();
char[16] buf;
WriteBuffer write_buf;
write_buf.init(&out, buf[..]);
@@ -56,7 +56,7 @@ fn void writebuffer()
ByteReader br;
br.init(DATA);
ByteWriter out;
out.temp_init();
out.tinit();
char[3] buf;
WriteBuffer write_buf;
write_buf.init(&out, buf[..]);
@@ -71,7 +71,7 @@ fn void writebuffer()
fn void writebuffer_write_byte()
{
ByteWriter out;
out.temp_init();
out.tinit();
char[2] buf;
WriteBuffer write_buf;
write_buf.init(&out, buf[..]);

View File

@@ -4,7 +4,7 @@ import std::io;
fn void write_read()
{
ByteBuffer buffer;
buffer.new_init(0);
buffer.init(mem, 0);
defer buffer.free();
buffer.write("hello")!!;

View File

@@ -12,7 +12,7 @@ fn void bytestream()
usz len = s.read(&buffer)!!;
assert((String)buffer[:len] == "abc");
ByteWriter w;
w.new_init();
w.init(mem);
defer (void)w.destroy();
OutStream ws = &w;
ws.write("helloworld")!!;
@@ -44,7 +44,7 @@ fn void bytewriter_read_from()
InStream s = &r;
ByteWriter bw;
bw.temp_init();
bw.tinit();
bw.read_from(s)!!;
assert(bw.str_view() == data);

View File

@@ -3,7 +3,7 @@ module std::io @test;
fn void test_writing()
{
DString foo;
foo.new_init();
foo.init(mem);
defer foo.free();
OutStream s = &foo;
s.write("hello")!!;

View File

@@ -3,7 +3,7 @@ module std::io @test;
fn void test_multireader()
{
MultiReader mr;
mr.temp_init(
mr.init(mem,
&&wrap_bytes("foo"),
&&wrap_bytes(" "),
&&wrap_bytes("bar"),
@@ -12,7 +12,7 @@ fn void test_multireader()
defer mr.free();
ByteWriter w;
io::copy_to(&mr, w.temp_init())!!;
io::copy_to(&mr, w.tinit())!!;
String want = "foo bar!";
assert(w.str_view() == want,

View File

@@ -4,7 +4,7 @@ fn void test_multiwriter()
{
ByteWriter w1, w2;
MultiWriter mw;
mw.temp_init(w1.temp_init(), w2.temp_init());
mw.tinit(w1.tinit(), w2.tinit());
defer mw.free();
String want = "foobar";

View File

@@ -27,7 +27,7 @@ fn void read_uint128_test()
fn void write_ushort_test()
{
ByteWriter bw;
bw.temp_init();
bw.tinit();
io::write_be_short(&bw, 0x348a)!!;
assert(bw.str_view() == &&x'348a');
}
@@ -35,7 +35,7 @@ fn void write_ushort_test()
fn void write_uint_test()
{
ByteWriter bw;
bw.temp_init();
bw.tinit();
io::write_be_int(&bw, 0x3421348a)!!;
assert(bw.str_view() == &&x'3421348a');
}
@@ -43,7 +43,7 @@ fn void write_uint_test()
fn void write_ulong_test()
{
ByteWriter bw;
bw.temp_init();
bw.tinit();
io::write_be_long(&bw, 0xaabbccdd3421348a)!!;
assert(bw.str_view() == &&x'aabbccdd3421348a');
}
@@ -51,7 +51,7 @@ fn void write_ulong_test()
fn void write_uint128_test()
{
ByteWriter bw;
bw.temp_init();
bw.tinit();
io::write_be_int128(&bw, 0xaabbccdd3421348aaabbccdd3421348a)!!;
assert(bw.str_view() == &&x'aabbccdd3421348aaabbccdd3421348a');
}
@@ -59,7 +59,7 @@ fn void write_uint128_test()
fn void write_tiny_bytearray_test()
{
ByteWriter bw;
bw.temp_init();
bw.tinit();
io::write_tiny_bytearray(&bw, &&x"aabbcc00112233")!!;
assert(bw.str_view() == &&x'07aabbcc00112233');
}
@@ -67,7 +67,7 @@ fn void write_tiny_bytearray_test()
fn void write_short_bytearray_test()
{
ByteWriter bw;
bw.temp_init();
bw.tinit();
io::write_short_bytearray(&bw, &&x"aabbcc00112233")!!;
assert(bw.str_view() == &&x'0007aabbcc00112233');
}

View File

@@ -5,7 +5,7 @@ fn void test_teereader()
String want = "foobar";
ByteWriter w;
TeeReader r = tee_reader((ByteReader){}.init(want), w.temp_init());
TeeReader r = tee_reader((ByteReader){}.init(want), w.tinit());
char[16] buf;
usz n = r.read(buf[..])!!;

View File

@@ -77,7 +77,7 @@ module sort_test @test;
fn void countingsort_list()
{
CountingSortTestList list;
list.temp_init();
list.tinit();
list.add_array({ 2, 1, 3});
sort::countingsort(list, &sort::key_int_value);
assert(check::int_ascending_sort(list.array_view()));

View File

@@ -83,7 +83,7 @@ def InsertionSortTestList = List(<int>);
fn void insertionsort_list()
{
InsertionSortTestList list;
list.temp_init();
list.tinit();
list.add_array({ 2, 1, 3});
sort::insertionsort(list, &sort::cmp_int_value);
assert(check::int_ascending_sort(list.array_view()));

View File

@@ -83,7 +83,7 @@ def List = List(<int>);
fn void quicksort_list()
{
List list;
list.temp_init();
list.tinit();
list.add_array({ 2, 1, 3});
sort::quicksort(list, &sort::cmp_int_value);
assert(check::int_sort(list.array_view()));

View File

@@ -20,7 +20,7 @@ fn void init_destroy_unbuffered() @test
for (usz i = 0; i < 20; i++)
{
UnbufferedChannel(<int>) c;
c.new_init()!!;
c.init(mem)!!;
defer c.destroy()!!;
}
}
@@ -37,7 +37,7 @@ fn void push_to_buffered_channel_no_lock() @test
fn void push_pop_buffered_no_locks() @test
{
BufferedChannel(<int>) c;
c.new_init(1)!!;
c.init(mem, 1)!!;
defer c.destroy()!!;
c.push(123)!!;
@@ -48,7 +48,7 @@ fn void push_pop_buffered_no_locks() @test
fn void push_pop_unbuffered_with_locks() @test
{
UnbufferedChannel(<int>) c;
c.new_init()!!;
c.init(mem)!!;
defer c.destroy()!!;
Thread thread;
@@ -71,7 +71,7 @@ fn void push_pop_unbuffered_with_locks() @test
fn void sending_to_closed_unbuffered_chan_is_forbidden() @test
{
UnbufferedChannel(<int>) c;
c.new_init()!!;
c.init(mem)!!;
defer c.destroy()!!;
c.close()!!;
@@ -87,7 +87,7 @@ fn void sending_to_closed_unbuffered_chan_is_forbidden() @test
fn void sending_to_closed_buffered_chan_is_forbidden() @test
{
BufferedChannel(<int>) c;
c.new_init(1)!!;
c.init(mem, 1)!!;
defer c.destroy()!!;
c.close()!!;
@@ -103,7 +103,7 @@ fn void sending_to_closed_buffered_chan_is_forbidden() @test
fn void reading_from_empty_closed_unbuffered_chan_is_forbidden() @test
{
UnbufferedChannel(<int>) c;
c.new_init()!!;
c.init(mem)!!;
defer c.destroy()!!;
c.close()!!;
@@ -119,7 +119,7 @@ fn void reading_from_empty_closed_unbuffered_chan_is_forbidden() @test
fn void reading_from_empty_closed_buffered_chan_is_forbidden() @test
{
BufferedChannel(<int>) c;
c.new_init(1)!!;
c.init(mem, 1)!!;
defer c.destroy()!!;
c.close()!!;
@@ -135,7 +135,7 @@ fn void reading_from_empty_closed_buffered_chan_is_forbidden() @test
fn void reading_from_non_empty_closed_buffered_chan_is_ok() @test
{
BufferedChannel(<int>) c;
c.new_init(3)!!;
c.init(mem, 3)!!;
defer c.destroy()!!;
c.push(1)!!;
@@ -164,7 +164,7 @@ fn void reading_from_non_empty_closed_buffered_chan_is_ok() @test
fn void reading_from_empty_buffered_chan_aborted_by_close() @test
{
BufferedChannel(<int>) c;
c.new_init(3)!!;
c.init(mem, 3)!!;
defer c.destroy()!!;
Thread thread;
@@ -190,7 +190,7 @@ fn void reading_from_empty_buffered_chan_aborted_by_close() @test
fn void reading_from_unbuffered_chan_aborted_by_close() @test
{
UnbufferedChannel(<int>) c;
c.new_init()!!;
c.init(mem)!!;
defer c.destroy()!!;
Thread thread;
@@ -216,7 +216,7 @@ fn void reading_from_unbuffered_chan_aborted_by_close() @test
fn void sending_to_full_buffered_chan_aborted_by_close() @test
{
BufferedChannel(<int>) c;
c.new_init(1)!!;
c.init(mem, 1)!!;
defer c.destroy()!!;
c.push(1)!!;
@@ -244,7 +244,7 @@ fn void sending_to_full_buffered_chan_aborted_by_close() @test
fn void sending_to_unbuffered_chan_aborted_by_close() @test
{
UnbufferedChannel(<int>) c;
c.new_init()!!;
c.init(mem, )!!;
defer c.destroy()!!;
Thread thread;
@@ -270,7 +270,7 @@ fn void sending_to_unbuffered_chan_aborted_by_close() @test
fn void multiple_actions_unbuffered() @test
{
UnbufferedChannel(<int>) c;
c.new_init()!!;
c.init(mem, )!!;
defer c.destroy()!!;
Thread thread;
@@ -304,7 +304,7 @@ fn void multiple_actions_unbuffered() @test
fn void multiple_actions_buffered() @test
{
BufferedChannel(<int>) c;
c.new_init(10)!!;
c.init(mem, 10)!!;
defer c.destroy()!!;
Thread thread;