This way people can use `const` with a `std.EnumMap`
and be able to `getPtrAssertContains(...)` like the
would with a mutable `var` instance.
Aligns with the existing `getPtr(...)`/`getPtrConst(...)`
methods.
previously when T was smaller than 8 bits, it was possible for base
to overflow T (because base is a u8). this patch prevents this by
accumulating into a U rather than T which is at least 8 bits wide.
this is the best way i could think of to maintain performance. this
will only affect parsing of integers less than 8 bits by adding one
additional cast at return. additionally, this patch may be slightly
slower to return an error for integers less than 8 bits which overflow
because it will accumulate a few more digits before the overflow check
at return.
* add tests which previously overflowed when they shouldn't have
closes#18157
* std.debug: optimized printLineFromFileAnyOs
Uses mem.indexOfScalar to speed line iteration instead of byte for byte.
Also prints the whole line in a single write (or up to a page size at a
time)
Closes#18099
* add test cases for printLineFromFileAnyOs
reads on eg. connected TCP sockets can fail with ETIMEDOUT, and ENOTCONN
happens eg. if you try to read a TCP socket that has not been connected
yet.
interestingly read() was already handling CONNRESET & TIMEDOUT, but
readv(), pread(), and preadv() were somewhat inconsistent.
This duplicates the source file string (as is done in other places such
as `addAssemblyFile()`) in order to prevent a segfault when the supplied
string is freed by the caller. This is still seen when the caller makes
use of a defer statement.
This reverts commit 8b10970836.
This implementation has the following problems:
* It does not provide context to the less than function. This will be an
API break in order to fix.
* It uses recursion, causing unbounded stack memory usage - likely
depending on user input, which is extra problematic.
* Sorting linked lists is generally an inefficient operation;
encouraging it by having a standard library function for it may
lead to suboptimal software being written in Zig.
Furthermore, there is almost no benefit to providing a sort function as
a method, when a third party implementation can easily be passed a
linked list to then be sorted.