Commit Graph

38 Commits

Author SHA1 Message Date
Feoramund
c8a62ee4ec Make simd_util index procs contextless where applicable 2024-08-09 18:54:04 -04:00
Feoramund
12dd0cb72a Simplify and make simd_util cross-platform
This new algorithm uses a Scalar->Vector->Scalar iteration loop which
requires no masking off of any incomplete data chunks.

Also, the width was reduced to 32 bytes instead of 64, as I found this
to be about as fast as the previous 64-byte x86 version.
2024-08-09 18:54:04 -04:00
Feoramund
f66fcd9acb Use vectorized index_* procs in core 2024-08-06 15:19:05 -04:00
Yawning Angel
dcaf085bfa core/bytes: Add alias and alias_inexactly 2024-07-16 01:29:43 +09:00
Jeroen van Rijn
a27b167218 Update tests\core\encoding\cbor to use new test runner.
It was leaky and required a substantial number of `loc := #caller_location` additions to parts of the core library to make it easier to track down how and where it leaked.

The tests now run fine multi-threaded.
2024-06-02 14:47:07 -04:00
Laytan Laats
d3bd1c2110 improve some Negative_Read/Negative_Write logic
Returns the actual error if one is set, instead of swallowing it for the
less descriptive negative error.

Also fixes a out-of-bounds slice error in `bufio.writer_write` because
it wasn't checking the returned `m`.
2024-04-25 19:08:48 +02:00
FourteenBrush
05e27fa92d Fix typo in bytes.scrub 2024-01-17 13:37:06 +01:00
Jeroen van Rijn
99d6a077fe _buffer_grow: Preserve allocator if already set via init_buffer_allocator
Fixes #2756
2023-08-18 22:16:59 +02:00
gingerBill
3f6775e29b Update to new io interface 2023-06-08 16:35:24 +01:00
Laytan Laats
7a04b7262e fix bytes.buffer_init_allocator not using given allocator if len/cap is 0 2023-05-09 21:25:15 +02:00
gingerBill
c4d19dfa92 Use uint instead of int to improve code generation for bounds checking 2022-09-27 22:31:46 +01:00
gingerBill
f50fc33749 Clean up of the core library to make the stream vtables not be pointers directly. 2022-09-15 10:00:50 +01:00
gingerBill
d3081bd889 Add buffer_read_ptr and buffer_write_ptr 2022-07-14 15:26:50 +01:00
gingerBill
33895b6d92 Convert all uses of *_from_slice to *_from_bytes where appropriate 2022-05-16 01:43:43 +01:00
gingerBill
ccb38c3dc6 Add _safe versions 2022-05-12 12:54:14 +01:00
gingerBill
2e7157ae9c Correct bytes._split_iterator 2022-02-14 11:01:34 +00:00
gingerBill
f561147190 Correct _split_iterator 2022-02-14 10:57:29 +00:00
gingerBill
a032a2ef32 Remove the hidden NUL byte past the end from bytes.clone 2022-01-01 15:33:19 +00:00
gingerBill
85f8c8df91 Fix fields_proc in strings and bytes 2021-12-11 12:04:34 +00:00
gingerBill
251da264ed Remove unneeded semicolons from the core library 2021-08-31 22:21:13 +01:00
Jeroen van Rijn
ae0b8fce44 Move bytes utils back to EXR code for the time being.
Also, allow PNG example to be run directly from `core:image/png` directory.
2021-06-22 16:39:00 +02:00
Jeroen van Rijn
352494cbb4 ZLIB: Start optimization. 2021-06-21 21:05:52 +02:00
Jeroen van Rijn
8a4b9ddaa3 Fix comment. 2021-06-18 15:42:04 +02:00
Jeroen van Rijn
54a2b6f00e Add bytes.buffer_create_of_type and bytes.buffer_convert_to_type.
Convenience functions to reinterpret or cast one buffer to another type, or create a buffer of a specific type.

	Example:
```odin
	fmt.println("Convert []f16le (x2) to []f32 (x2).");
	b := []u8{0, 60, 0, 60}; // == []f16{1.0, 1.0}

	res, backing, had_to_allocate, err := bytes.buffer_convert_to_type(2, f32, f16le, b);
	fmt.printf("res      : %v\n", res);              // [1.000, 1.000]
	fmt.printf("backing  : %v\n", backing);          // &Buffer{buf = [0, 0, 128, 63, 0, 0, 128, 63], off = 0, last_read = Invalid}
	fmt.printf("allocated: %v\n", had_to_allocate);  // true
	fmt.printf("err      : %v\n", err);              // false

	if had_to_allocate { defer bytes.buffer_destroy(backing); }

	fmt.println("\nConvert []f16le (x2) to []u16 (x2).");

	res2: []u16;
	res2, backing, had_to_allocate, err = bytes.buffer_convert_to_type(2, u16, f16le, b);
	fmt.printf("res      : %v\n", res2);             // [15360, 15360]
	fmt.printf("backing  : %v\n", backing);          // Buffer.buf points to `b` because it could be converted in-place.
	fmt.printf("allocated: %v\n", had_to_allocate);  // false
	fmt.printf("err      : %v\n", err);              // false

	if had_to_allocate { defer bytes.buffer_destroy(backing); }

	fmt.println("\nConvert []f16le (x2) to []u16 (x2), force_convert=true.");

	res2, backing, had_to_allocate, err = bytes.buffer_convert_to_type(2, u16, f16le, b, true);
	fmt.printf("res      : %v\n", res2);             // [1, 1]
	fmt.printf("backing  : %v\n", backing);          // Buffer.buf points to `b` because it could be converted in-place.
	fmt.printf("allocated: %v\n", had_to_allocate);  // false
	fmt.printf("err      : %v\n", err);              // false

	if had_to_allocate { defer bytes.buffer_destroy(backing); }
```
2021-06-18 15:25:36 +02:00
gingerBill
86649e6b44 Core library clean up: Make range expressions more consistent and replace uses of .. with ..= 2021-06-14 11:15:25 +01:00
gingerBill
e82f8214e8 Add bytes.remove, bytes.remove_all, strings.remove, strings.remove_all 2021-05-23 11:46:43 +01:00
gingerBill
d33350e3a5 Add truncate_to_byte and truncate_to_rune for packages strings and bytes 2021-04-22 15:49:10 +01:00
gingerBill
cd2476e084 Add buffer_read_at buffer_write_at 2021-04-14 20:13:26 +01:00
gingerBill
3337412228 split*_iterator procedures for package bytes and strings 2021-03-18 13:26:33 +00:00
gingerBill
aa93305015 Replace usage of inline proc with #force_inline proc in the core library 2021-02-23 16:14:47 +00:00
gingerBill
e6dfc22b8a Add bytes.buffer_write_to and bytes.buffer_read_from 2020-12-17 00:47:05 +00:00
gingerBill
1470cab842 Make bytes.odin consistent with strings.odin in functionality 2020-12-17 00:36:25 +00:00
gingerBill
a31b992d2b Rename bytes/strings.odin to bytes/bytes.odin 2020-12-17 00:25:05 +00:00
gingerBill
a82c902f99 Minor correction to bytes.Buffer's vtable 2020-12-05 15:36:02 +00:00
gingerBill
0ed1300bd6 Make bytes.Reader and strings.Reader have the same interface 2020-12-04 21:25:13 +00:00
gingerBill
dd63665b58 Update bytes.Reader 2020-12-04 20:33:14 +00:00
gingerBill
9b22583397 Add bytes.Buffer 2020-12-04 20:18:41 +00:00
gingerBill
63f2480951 Begin work on package bytes ([]byte equivalent of package strings) 2020-12-04 19:16:40 +00:00