summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2023-05-07Everywhere: Change spelling of 'behaviour' to 'behavior'Ben Wiederhake
"The official project language is American English […]." https://github.com/SerenityOS/serenity/blob/5d2e9156239cd707a22ecea6c87d48e5fc1cbe84/CONTRIBUTING.md?plain=1#L30 Here's a short statistic of the occurrences of the word "behavio(u)r": $ git grep -IPioh 'behaviou?r' | sort | uniq -c | sort -n 2 BEHAVIOR 24 Behaviour 32 behaviour 407 Behavior 992 behavior Therefore, it is clear that "behaviour" (56 occurrences) should be regarded a typo, and "behavior" (1401 occurrences) should be preferred. Note that The occurrences in LibJS are intentionally NOT changed, because there are taken verbatim from the specification. Hence: $ git grep -IPioh 'behaviou?r' | sort | uniq -c | sort -n 2 BEHAVIOR 10 behaviour 24 Behaviour 407 Behavior 1014 behavior
2023-05-07Everywhere: Run spellcheck on all documentationBen Wiederhake
2023-05-04AK: Prevent bit counter underflows in the new BitStreamTim Schumacher
Our current `peek_bits` function allows retrieving more bits than we can actually provide, so whenever someone discards the requested bit count afterwards we were underflowing the value instead.
2023-05-03AK: Have `JsonArray::set()` change values instead of inserting valuesKemal Zebari
Resolves #18618. 8134dcc changed `JsonArray::set()` to insert elements at an index instead of changing existing elements in-place. Since no behavior such as `Vector::try_at()` exists yet, it returns nothing.
2023-05-02AK: Accomodate always-32-bit data member pointers in IntrusiveListAli Mohammad Pur
This only exists on windows, but we've made an effort to keep jakt working on windows, so let's support this silliness.
2023-05-02Everywhere: Make Lagom build with GCC 13Daniel Bertalan
GCC 13 was released on 2023-04-26. This commit fixes Lagom build errors when using an updated host toolchain: - Adds a workaround for a bug in constraint handling, which made LibJS fail to compile: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683 - Silences the new `-Wdangling-reference` diagnostic globally. It produces multiple false positives with no clear way to silence them without `#pragmas`. - Silences `-Wself-move` in `RefPtr` tests as GCC 13 adds this previously Clang-exclusive warning.
2023-04-30AK: Replace linear exponentiation by binary in MinimalBigIntDan Klishch
This further optimizes floating point parsing (specifically with a large amount of digits). The commit shaves additional 20% of the run time for 750-digit numbers. No performance degradation is noticeable for small numbers.
2023-04-30AK: Use helpers from BigIntBase.h in MinimalBigIntDan Klishch
Although it might seem like we've switched to more generic functions, which must run slower, it is not the case. The time required to parse "1", for example, decreased by 1%. For numbers with more digits, the effect is more noticeable: 8-digit numbers are parsed ~5% faster; for gigantic 750-digit numbers, parsing is 2 times faster. The later result is achieved by using UFixedBigInt<64>::wide_multiply instead of u128::operator*(u128).
2023-04-30AK: Move taint_for_optimizer to StdLibExtras.hDan Klishch
Additionally, split it into two versions (for IsIntegral<T> -- asking to place value into register and for !IsIntegral<T> -- asking to place value into memory with memory clobber), so that Clang is no more completely confused about `taint_for_optimizer(AK::StringView&)`.
2023-04-30AK: Add count() helper to Stringthankyouverycool
2023-04-29AK: Add `Span::align_to`Daniel Bertalan
This method returns a sub-span whose data pointer and size is aligned to a specified alignment.
2023-04-28AK: Add values() method in HashTableAliaksandr Kalenik
Add HashTable::values() method that returns all values.
2023-04-28AK: Make the Optional formatter always available and tweak its formatAli Mohammad Pur
There's no real reason to make this a debug-only formatter, on top of that, jakt has a optional formatter that prints None/foo instead of OptionalNone/Optional(foo), which is more concise anyway, so switch to that.
2023-04-28AK+LibTimeZone: Add debug only formatter for OptionalMacDue
I found this handy for debugging, and so might others. This now also adds a formatter for TimeZone::TimeZone. This is needed for FormatIfSupported<Optional<TimeZone::TimeZone>> to compile. As FormatIfSupported sees a formatter for Optional exists, but not that there's not one for TimeZone::TimeZone.
2023-04-28AK: Don't refer to AK::swap() as ::swap()Ali Mohammad Pur
While swap() is available in the global namespace in normal conditions, !USING_AK_GLOBALLY will make this name unavailable in the global namespace, making these calls fail to compile.
2023-04-28AK+Everywhere: Disallow Error::from_string_view(FooString)Ali Mohammad Pur
That pattern seems to show up a lot in code written by people that aren't intimately familiar with the lifetime model of Error and Strings. This commit makes the compiler detect it and present a more helpful diagnostic than "garbage string at runtime".
2023-04-26LibWasm: Start implementing WASIAli Mohammad Pur
This commit starts adding support for WASI, along with the framework to implement all the functions (though only a couple are currently implemented).
2023-04-25AK: Rename `Stream::format()` to `Stream::write_formatted()`Tim Schumacher
This brings the function name in line with how we usually name those functions, which is with a `read_` or `write_` prefix depending on what they do. While at it, make the internal `_impl` function private and not-virtual, since there is no good reason to ever override that function.
2023-04-24AK: Use `JsonArray::append` when parsing arrayCameron Youell
2023-04-24AK: Add new failable `JsonArray::{append/set}` functionsCameron Youell
Move all old usages to the more explicit `JsonArray:must_{append/set}`
2023-04-23LibThreading: Create WorkerThread class run a single task concurrentlyZaggy1024
This class can be used to run a task in another thread, and allows the caller to wait for the task to complete to retrieve any error that may have occurred. Currently, it doesn't support functions returning a value on success, but with some template magic that should be possible. :^)
2023-04-23AK: Implement Stream::format(fmtstr, args...)Peter Brottveit Bock
Based on `out()` and `vout()` from AK/Format.h. As opposed to those, this propagates errors. As `Core::File` extends `AK::Stream`, this allows formatted printing directly on `Core::File`s.
2023-04-21AK: Add Array::contains_slow() and ::first_index_of(), with tests :^)Sam Atkins
2023-04-21AK: Fix crash during teardown of self-owning objectsAndreas Kling
We now null out smart pointers *before* calling unref on the pointee. This ensures that the same smart pointer can't be used to acquire a new reference to the pointee after its destruction has begun. I ran into this when destroying a non-empty IntrusiveList of RefPtrs, but the problem was more general so this fixes it for all of RefPtr, NonnullRefPtr, OwnPtr and NonnullOwnPtr.
2023-04-15AK+Everywhere: Replace URL::paths() with path_segment_at_index()MacDue
This allows accessing and looping over the path segments in a URL without necessarily allocating a new vector if you want them percent decoded too (which path_segment_at_index() has an option for).
2023-04-15AK+Everywhere: Change URL::path() to serialize_path()MacDue
This now defaults to serializing the path with percent decoded segments (which is what all callers expect), but has an option not to. This fixes `file://` URLs with spaces in their paths. The name has been changed to serialize_path() path to make it more clear that this method will generate a new string each call (except for the cannot_be_a_base_url() case). A few callers have then been updated to avoid repeatedly calling this function.
2023-04-15AK+Everywhere: Add ApplyPercentDecoding option to URL gettersMacDue
The defaults selected for this are based on the behaviour of URL when it applied percent decoding during parsing. This does mean now in some cases the getters will allocate, but percent_decode() checks if there's anything to decode first, so in many cases still won't.
2023-04-15AK: Remove unnecessary parameter names in URL.hMacDue
2023-04-14AK: Remove workaround for old macOS SDKNico Weber
https://github.com/SerenityOS/serenity/pull/9716#issuecomment-1508606204 has details.
2023-04-14AK: Remove unused AK_ARCH_ definesNico Weber
ARCH() uses the AK_IS_ARCH_ macros internally since 349e54d5375a4a, and all user code uses the ARCH() macro instead of AK_ARCH_. (Why it's called ARCH() and not AK_ARCH(), I don't know.) If any ports not in the main repo use AK_ARCH_, they should switch to using ARCH() instead.
2023-04-14Everywhere: Use ARCH(AARCH64) instead of AK_ARCH_AARCH64Nico Weber
The former is typo-resistant after 349e54d5375a4a, so make use of that.
2023-04-14AK: Make math work on arm hosts againNico Weber
957f89ce4abb6ad added some tweaks for serenity-on-aarch64. It broke anythingelse-on-aarch64 hosts though, so only do these tweaks when targeting serenity. (I wonder if AK/Math.h should fall back to the system math routines when not targeting serenity in general. Would probably help ladybird performance. On the other hand, the serenity routines would see less use and hence exposure and love.)
2023-04-14AK: Efficiently resize CircularBuffer seekback copy distanceTim Schumacher
Previously, if we copied the last byte for a length of 100, we'd recalculate the read span 100 times and memmove one byte 100 times, which resulted in a lot of overhead. Now, if we know that we have two consecutive copies of the data, we just extend the distance to cover both copies, which halves the number of times that we recalculate the span and actually call memmove. This takes the running time of the attached benchmark case from 150ms down to 15ms.
2023-04-13AK: Add very naive implementation of {sin,cos,tan} for aarch64Timon Kruiper
The {sin,cos,tan} functions in AK are used as the implementation of the same function in libm. We cannot use the __builtin_foo functions as these would just call the libc functions. This was causing an infinite loop. Fix this by adding a very naive implementation of AK::{sin, cos,tan}, that is only valid for small inputs. For the other functions in this file, I added a TODO() such that we'll crash, instead of infinite looping.
2023-04-13AK+Tests: Add Vector::find_first_index_if()Sam Atkins
2023-04-12Everywhere: Fix a few typosNico Weber
Some even user-visible!
2023-04-12AK: Make grepping for "lerp" find mix()Nico Weber
2023-04-12AK: Remove the Endian bytes accessorTim Schumacher
This is a remnant from when we didn't have a `read_value` and `write_value` implementation for `AK::Endian` and instead used the generic functions for reading a span of bytes. Now that we have a more ergonomic alternative, remove the helper that is no longer needed.
2023-04-12AK: Don't store parts of URLs percent decodedMacDue
As noted in serval comments doing this goes against the WC3 spec, and breaks parsing then re-serializing URLs that contain percent encoded data, that was not encoded using the same character set as the serializer. For example, previously if you had a URL like: https:://foo.com/what%2F%2F (the path is what + '//' percent encoded) Creating URL("https:://foo.com/what%2F%2F").serialize() would return: https://foo.com/what// Which is incorrect and not the same as the URL we passed. This is because the re-serializing uses the PercentEncodeSet::Path which does not include '/'. Only doing the percent encoding in the setters fixes this, which is required to navigate to Google Street View (which includes a percent encoded URL in its URL). Seems to fix #13477 too
2023-04-11AK+Everywhere: Use Optional for URLParser::parse's base_url parameternetworkException
2023-04-11AK: Allow human_readable_size_long to use a thousands separatorTim Ledbetter
2023-04-11AK: Add option to the string formatter to use a digit separatorTim Ledbetter
`vformat()` can now accept format specifiers of the form {:'[numeric-type]}. This will output a number with a comma separator every 3 digits. For example: `dbgln("{:'d}", 9999999);` will output 9,999,999. Binary, octal and hexadecimal numbers can also use this feature, for example: `dbgln("{:'x}", 0xffffffff);` will output ff,fff,fff.
2023-04-09LibCore: Fix corner case for files without newlinesRodrigo Tobar
When BufferedFile.can_read_line() was invoked on files with no newlines, t incorrectly returned a false result for this single line that, even though doesn't finish with a newline character, is still a line. Since this method is usually used in tandem with read_line(), users would miss reading this line (and hence all the file contents). This commit fixes this corner case by adding another check after a negative result from finding a newline character. This new check does the same as the check that is done *before* looking for newlines, which takes care of this problem, but only works for files that have at least one newline (hence the buffer has already been filled). A new unit test has been added that shows the use case. Without the changes in this commit the test fails, which is a testament that this commit really fixes the underlying issue.
2023-04-08AK: Bake CLion IDE check into AK_COMPILER_CLANGAndreas Kling
For whatever reason, when CLion does its code indexing thing, it doesn't define __clang__ despite using Clang. This causes it to run into various problems that we've solved by checking for Clang. Since CLion does define __CLION_IDE__ (or sometimes __CLION_IDE_, no idea why but I have seen this issue locally), let's make that part of the AK_COMPILER_CLANG check. This makes CLion stop highlighting various things as errors.
2023-04-07AK: Allow specifying a minimum value for IDs returned by IDAllocatorTimothy Flynn
2023-04-06AK: Add FlyString::is_one_of for variadic string comparisonKenneth Myhra
2023-04-06AK: Add to_string() for IPv4Addressstelar7
2023-04-05AK+LibCompress: Break when seekback copying to a full CircularBufferTim Schumacher
Otherwise, we just end up infinitely looping while waiting for more space in the destination.
2023-04-05AK: Report copied bytes when seekback copying from CircularBufferTim Schumacher
Otherwise, we have no way of determining whether our copy was truncated by accident.
2023-04-05AK: Properly limit the internal seekback span for CircularBufferTim Schumacher
I was originally thinking in the wrong direction when adding this limit, we can at most read from the buffer until we reach the current write head. Since that write head is the reference point for the distance, we need to limit ourselves to that instead of the seekback limit (which is the maximum of how far back the distance can be).