Commit Graph

60 Commits

Author SHA1 Message Date
gingerBill
e4fcebe4bf Empty -> Unsupported 2025-11-14 11:17:38 +00:00
Jeroen van Rijn
7a9ea3ee6d Further overhaul of package line comments. 2025-10-09 23:05:29 +02:00
Jeroen van Rijn
248b0fe9e1 More package lines 2025-10-09 16:11:33 +02:00
gingerBill
3e8f4e080c Add more doc lines 2025-10-09 12:26:35 +01:00
gingerBill
20e67f2ad9 Add some more docs 2025-10-07 14:27:19 +01:00
Feoramund
45219f240e Rename SIMD_IS_EMULATED to capability-affirmative HAS_HARDWARE_SIMD 2025-05-29 17:17:51 -04:00
Laytan Laats
5ae27c6ebc wasm: support more vendor libraries
Adds support for:
- box2d
- cgltf
- stb image
- stb rect pack
2024-09-09 18:49:13 +02:00
laytan
a99e57c62c bytes: fix last_index_byte off-by-one 2024-09-05 13:30:46 +02:00
Feoramund
f453054aff Return 0, nil in all io cases where an empty slice is provided 2024-08-28 19:53:20 +02:00
Feoramund
6798d15ecb Check int(abs) instead to avoid overflows 2024-08-28 19:53:20 +02:00
Feoramund
e83b982afe Measure bytes.Buffer size by length instead of capacity 2024-08-28 19:53:20 +02:00
Feoramund
7c6cc81041 Add Seek behavior to bytes.Buffer 2024-08-28 19:53:20 +02:00
Feoramund
521e47ffee Don't invalidate prev_rune if Reader seek failed 2024-08-28 19:53:20 +02:00
Feoramund
8251f4d7d0 Return .EOF in bytes.buffer_read_at instead
This is consistent with the other stream `read` procs
2024-08-28 19:53:20 +02:00
Feoramund
da49f7eb4e Make bytes.reader_init return an io.Stream
Makes the API like the other stream `init` procs.
2024-08-28 19:53:20 +02:00
Feoramund
981a2e1a00 Add missing io.Stream_Mode responses 2024-08-28 19:53:19 +02:00
Rory OConnell
97795ff3a2 fix simd var typo 2024-08-19 15:50:42 -07:00
Yawning Angel
9e65e229d0 core/bytes: Tweak index_byte and last_index_byte
- Assume unaligned loads are cheap
- Explicilty use 256-bit or 128-bit SIMD to avoid AVX512
- Limit "vectorized" scanning to 128-bits if SIMD is emulated via SWAR
- Add a few more benchmark cases
2024-08-19 11:40:36 +09:00
gingerBill
62911539cd Minor style change 2024-08-13 14:27:25 +01:00
Feoramund
5d5addd48f Set SIMD_SCAN_WIDTH based on size_of(uintptr) 2024-08-10 07:43:14 -04:00
Feoramund
c69fa87d53 Merge core:simd/util into core:bytes 2024-08-10 07:17:03 -04:00
Feoramund
0d29cc3375 Use for x in y construct for bytes iteration
This cannot be applied to the `strings` version, as that would cause a
rune-by-rune iteration, not a byte-by-byte one.
2024-08-09 18:54:04 -04:00
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