summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2022-06-10AK: Make URL ApplicationXWWWFormUrlencoded encoding closer to specKarol Kosek
It was mostly implemented based on a spec note, that described only allowed characters, but instead of allowing some special characters not to be escaped, we escaped every special character except those 'new in this encode set' disallowed characters from the spec definition.
2022-06-10AK: Append correct number of port characters when serializing a URLKarol Kosek
Instead of formatting a port string, it put bytes from stack, using the port number as a length (so for port 8000 it appended 8000 bytes).
2022-06-10AK: Add SinglyLinkedList::prepend()Tim Schumacher
2022-06-09AK: Add Error::operator==(Error const&)Lucas CHOLLET
2022-05-26AK: Add invert_case() and invert_case(StringView)huttongrabiel
In the given String, invert_case() swaps lowercase characters with uppercase ones and vice versa.
2022-05-21AK: Use static_cast to cast to base typeAli Mohammad Pur
This is an issue on systems that don't have the empty base class optimisation (such as windows), and we normally don't need to care - however static_cast is technically the right thing to use, so let's use that instead. Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-05-12AK+DHCPClient: Fix false positive gcc 12 warningsDaniel Bertalan
The compiler would complain about `__builtin_memcpy` in ByteBuffer::copy writing out of bounds, as it isn't able to deduce the invariant that the inline buffer is only used when the requested size is smaller than the inline capacity. The other change is more bizarre. If the destructor's declaration exists, gcc complains about a `delete` operation causing an out-of-bounds array access. error: array subscript 'DHCPv4Client::__as_base [0]' is partly outside array bounds of 'unsigned char [8]' [-Werror=array-bounds] 14 | ~DHCPv4Client() = default; | ^ This looks like a compiler bug, and I'll report it if I find a suitable reduced reproducer.
2022-05-09AK: Add `clamp(f32x4, float, float)`Jelle Raaijmakers
We are allowed to directly compare `f32x4` with a `float`, so make use of it.
2022-05-08AK+LibGUI: Pass predicate to *_matching() methods by const referenceVitaly Dyachkov
2022-05-08AK: Use AK:: sin and cos on aarch64 buildEWouters
This fixes the lagom build on aarch64, as `__builtin_sincosf` doesn't take double arguments.
2022-05-07AK: Use builtin versions of `llrint{,l,f}`EWouters
This fixes the build on M1 Macs.
2022-05-07AK: Add an SSE2 specific implementation of sqrt(double)Hendiadyoin1
2022-05-07AK: Add a cpp-y, more fine grained version of fenv.h: FPControl.hHendiadyoin1
This allows direct inlining and hides away some assembly and bit-fiddling when manipulating the floating point environment. This only implements the x87/SSE versions, as of now.
2022-05-07AK: Add an helper for quick hardware based roundingHendiadyoin1
This uses the `fistp` and `cvts[sd]2si` respectively, to potentially round floating point values with just one instruction. This falls back to `llrint[fl]?` on aarch64 for now.
2022-04-27AK: Put invalid UTF8 debug spam behind a flagkleines Filmröllchen
This is very annoying if we're (intentionally) passing invalid UTF8 into Utf8View.
2022-04-23AK: Make sure we don't include Math.h or math.h from KERNELAndrew Kaster
2022-04-21LibCore: Introduce SharedSingleProducerCircularQueuekleines Filmröllchen
This new class with an admittedly long OOP-y name provides a circular queue in shared memory. The queue is a lock-free synchronous queue implemented with atomics, and its implementation is significantly simplified by only accounting for one producer (and multiple consumers). It is intended to be used as a producer-consumer communication datastructure across processes. The original motivation behind this class is efficient short-period transfer of audio data in userspace. This class includes formal proofs of several correctness properties of the main queue operations `enqueue` and `dequeue`. These proofs are not 100% complete in their existing form as the invariants they depend on are "handwaved". This seems fine to me right now, as any proof is better than no proof :^). Anyways, the proofs should build confidence that the implemented algorithms, which are only roughly based on existing work, operate correctly in even the worst-case concurrency scenarios.
2022-04-21AK: Allow alignment to cache line size with CACHE_ALIGNEDkleines Filmröllchen
This is particularly important to avoid false sharing, which thrashes performance when two process-shared atomics are on the same cache line.
2022-04-21AK: Expose RedBlackTree::find_smallest_not_below()Tim Schumacher
2022-04-21AK: Make `Vector::contains_slow` templatedForLoveOfCats
This allows for calling this function with any argument type for which the appropriate traits and operators have been implemented so it can be compared to the Vector's item type
2022-04-21AK: Add `URL::create_with_help_scheme` helper functionForLoveOfCats
2022-04-20AK: Add FuzzyMatch headerfaxe1008
This patch adds a header containing the fuzzy match algorithm previously used in Assistant. The algorithm was moved to AK since there are many places where a search may benefit from fuzzyness.
2022-04-20AK: Explicitly instantiate String::to_uint<unsigned long{, long}>()Ali Mohammad Pur
Instead of just to_uint<u64>().
2022-04-20AK: Add a OneOfIgnoringCV conceptAli Mohammad Pur
Some functions want to ignore cv-qualifiers, and it's much easier to constrain the type through a concept than a separate requires clause on the function.
2022-04-17AK: Add Kernel namespace to KStrings in AK::IPv6AddressThitat Auareesuksakul
Currently there is no AK::IPv6Address in the kernel. But when there is, KStrings won't resolve properly because they are in Kernel namespace.
2022-04-14AK: Differ between long and long long formatsTim Schumacher
2022-04-14AK: Deduplicate formatting hexadecimal valuesTim Schumacher
Both calls essentially only differ in one boolean, which dictates whether to print the value in uppercase or lowercase. Move the long function call into a new function and pass in the "uppercase" boolean seperately to avoid having to write everything twice.
2022-04-14AK: Merge print_i64 into print_signed_numberTim Schumacher
Those functions only differ by the input type of `number`. No other wrapper does this, as they rely on adjusting the type of the argument on the caller side instead. Avoid specializing too much by just doing the same for signed numbers.
2022-04-13LibWeb: Make reverse iterators work for const NonnullPtrVectorsAndreas Kling
2022-04-10AK: Add missing include to Traits.hAndreas Kling
2022-04-10AK: Add hash traits for floating-point primitivesAndreas Kling
This allows us to use float and double as hash keys.
2022-04-10AK: Remove `KERNEL` check from `String`Jelle Raaijmakers
Since we no longer use `String` inside of the kernel code, we can drop this `#ifndef`.
2022-04-10AK: Don't destructively re-encode query strings in the URL parserAndreas Kling
We were decoding and then re-encoding the query string in URLs. This round-trip caused us to lose information about plus ('+') ASCII characters encoded as "%2B".
2022-04-10AK+LibWeb: Encode ' ' as '+' in application/x-www-form-urlencodedAndreas Kling
This matches what the URL and HTML specifications ask us to do.
2022-04-08AK+LibHTTP: Revert prior change to percent encode plus signsGeekFiftyFive
A change was made prior to percent encode plus signs in order to fix an issue with the Google cookie consent page. Unforunately, this was treating a symptom of a problem and not the root cause and is incorrect behavior.
2022-04-06AK+Userland: Rename Array::front/back to first/lastSam Atkins
This is the name that is used for every other collection type so let's be consistent.
2022-04-06AK: Add const version of Vector::first_matchingkleines Filmröllchen
2022-04-06AK: Add find_first_index to NonnullPtrVector that strips smart pointerkleines Filmröllchen
When we want to use the find_first_index that base Vector provides, we need to provide an element of the real contained type. That's impossible for OwnPtr, however, and even with RefPtr there might be instances where we have a raw reference to the object we want to find, but no smart pointer. Therefore, overloading this function (with an identical body, the magic is done by the find_index templatization) with `T const&` as a parameter allows there use cases.
2022-04-05AK: Invalidate UTF-8 encoded code points larger than U+10ffffTimothy Flynn
On oss-fuzz, the LibJS REPL is provided a file encoded with Windows-1252 with the following contents: /ô¡°½/ The REPL assumes the input file is UTF-8. So in Windows-1252, the above is represented as [0x2f 0xf4 0xa1 0xb0 0xbd 0x2f]. The inner 4 bytes are actually a valid UTF-8 encoding if we only look at the most significant bits to parse leading/continuation bytes. However, it decodes to the code point U+121c3d, which is not a valid code point. This commit adds additional validation to ensure the decoded code point itself is also valid.
2022-04-04AK: Make Vector<T>::{first,last}_matching() return Optional<T&>Ali Mohammad Pur
These functions are _very_ misleading, as `first()` and `last()` return references, but `{first,last}_matching()` return copies of the values. This commit makes it so that they now return Optional<T&>, eliminating the copy and the confusion.
2022-04-04AK: Return Optional<T&> from HashMap<..., T>::get()Ali Mohammad Pur
This avoids a useless copy of the value, as most of the users (except one) actually just need a reference to the value.
2022-04-04AK: Return Optional<ConstPeekType> for HashMap::get() constAli Mohammad Pur
While the previous implementation always copied the object, returning a non-const reference to a const object is not valid.
2022-04-04AK: Allow Optional<T&> to existAli Mohammad Pur
This implements Optional<T&> as a T*, whose presence has been missing since the early days of Optional. As a lot of find_foo() APIs return an Optional<T> which imposes a pointless copy on the underlying value, and can sometimes be very misleading, with this change, those APIs can return Optional<T&>.
2022-04-04AK: Add begin_from(V&) APIs to IntrusiveRedBlackTreeIdan Horowitz
This method exploits the fact that the values themselves hold the tree pointers, and as a result this let's us skip the O(logn) traversal down to the matching Node for a Key-Value pair.
2022-04-03AK: Add `StringView::copy_characters_to_buffer()`Tim Schumacher
2022-04-03AK: Add non-const iterator for CircularQueuekleines Filmröllchen
2022-04-03AK: Add generic sincos solution for non-x86 platformsserenityosrocks
2022-04-02AK: Add last() utility function to SpanBen Maxwell
2022-04-02AK+LibHTTP: Ensure plus signs are percent encoded in query stringGeekFiftyFive
Adds a new optional parameter 'reserved_chars' to AK::URL::percent_encode. This new optional parameter allows the caller to specify custom characters to be percent encoded. This is then used to percent encode plus signs by HttpRequest::to_raw_request.
2022-04-02AK: Add vector variants of sqrt and rsqrtHendiadyoin1