summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-04-14AK: Expose the decode_hex_digit helperIdan Horowitz
This helper is useful on its own for things like uri encoding/decoding, so this commit exposes it via the AK/Hex header
2021-04-12AK: Fix StringView::find_last_of for one-character viewsTimothy Flynn
The find_last_of implementations were breaking out of the search loop too early for single-character string views. This caused a crash in CookieJar setting a cookie on google.com - CookieJar::default_path knew there was at least one "/" in a string view, but find_last_of returned nullopt, so dereferencing the optional caused a crash. Fixes #6273
2021-04-12AK: Add a predicate variant of StringView::split_viewTimothy Flynn
2021-04-12AK: Implement IntrusiveRedBlackTree containerIdan Horowitz
This container is similar to the RedBlackTree container, but instead of transparently allocating tree nodes on insertion and freeing on removal this container piggybacks on intrusive node fields in the stored class
2021-04-12AK: Implement RedBlackTree containerIdan Horowitz
This container is based on a balanced binary search tree, and as such allows for O(logn) worst-case insertion, removal, and search, as well as O(n) sorted iteration.
2021-04-11AK: Update LexicalPath::relative_path to work for '/' prefixTim Waterhouse
If the prefix path is just a slash the LexicalPath was removing too many characters. Now only remove an extra character if the prefix is not just the root path.
2021-04-11AK: Annotate StringBuilder functions as [[nodiscard]]Brian Gianforcaro
2021-04-11AK: Annotate WeakPtr functions as [[nodiscard]]Brian Gianforcaro
2021-04-11AK: Annotate Trie functions as [[nodiscard]]Brian Gianforcaro
2021-04-11AK: Annotate StringView functions as [[nodiscard]]Brian Gianforcaro
2021-04-11AK: Annotate IntrusiveList functions as [[nodiscard]]Brian Gianforcaro
2021-04-11AK: Annotate HashTable functions as [[nodiscard]]Brian Gianforcaro
2021-04-11AK: Make HashTable with capacity constructor explicitBrian Gianforcaro
2021-04-11AK: Annotate HashMap functions with [[nodiscard]]Brian Gianforcaro
2021-04-11AK: Annotate DoublyLinkedList functions with [[nodiscard]]Brian Gianforcaro
2021-04-11AK: Annotate Checked functions with [[nodiscard]]Brian Gianforcaro
2021-04-10AK+Everywhere: Make StdLibExtras templates less wrapper-yAnotherTest
This commit makes the user-facing StdLibExtras templates and utilities arguably more nice-looking by removing the need to reach into the wrapper structs generated by them to get the value/type needed. The C++ standard library had to invent `_v` and `_t` variants (likely because of backwards compat), but we don't need to cater to any codebase except our own, so might as well have good things for free. :^)
2021-04-09AK: Add BitmapView::set_range_and_verify_that_all_bits_flip()Andreas Kling
This function sets a range of bits to the same value while also verifying that all bits in the range get flipped in the process.
2021-04-08Format: Strip trailing zeroes from floating point valuesJelle Raaijmakers
This is a pretty naive implementation that works well. The precision parameter is interpreted as "maximum precision" instead of "minimum precision", which in my opinion is the most useful interpretation.
2021-04-08Tests: Merge duplicate TestFormat test into AK directoryJelle Raaijmakers
2021-04-02AK: Inline HashTable writing bucket lookupthislooksfun
The old approach was more complex and also had a very bad edge case with lots of collisions. This approach eliminates that possiblility. It also makes both reading and writing lookups a little bit faster.
2021-04-02AK: Inline the bucket index calculationthislooksfun
The result of the modulo is only used in the array index, so why make the code more complex by calculating it in two different places?
2021-04-02AK: Add tests for HashTablethislooksfun
2021-04-02LibJS: Add initial support for PromisesLinus Groh
Almost a year after first working on this, it's finally done: an implementation of Promises for LibJS! :^) The core functionality is working and closely following the spec [1]. I mostly took the pseudo code and transformed it into C++ - if you read and understand it, you will know how the spec implements Promises; and if you read the spec first, the code will look very familiar. Implemented functions are: - Promise() constructor - Promise.prototype.then() - Promise.prototype.catch() - Promise.prototype.finally() - Promise.resolve() - Promise.reject() For the tests I added a new function to test-js's global object, runQueuedPromiseJobs(), which calls vm.run_queued_promise_jobs(). By design, queued jobs normally only run after the script was fully executed, making it improssible to test handlers in individual test() calls by default [2]. Subsequent commits include integrations into LibWeb and js(1) - pretty-printing, running queued promise jobs when necessary. This has an unusual amount of dbgln() statements, all hidden behind the PROMISE_DEBUG flag - I'm leaving them in for now as they've been very useful while debugging this, things can get quite complex with so many asynchronously executed functions. I've not extensively explored use of these APIs for promise-based functionality in LibWeb (fetch(), Notification.requestPermission() etc.), but we'll get there in due time. [1]: https://tc39.es/ecma262/#sec-promise-objects [2]: https://tc39.es/ecma262/#sec-jobs-and-job-queues
2021-04-01AK: Fix bogus return type of Result::release_error() (#6054)vcollette
The function was not used anywhere so the error was unnoticed.
2021-03-28AK: Add Signed/Unsigned concepts.Michel Hermier
2021-03-28AK: Add IsSigned conterpart to IsUnsigned.Michel Hermier
2021-03-28AK: Remove IsSigned<char> test as it is platform/compiler dependant.Michel Hermier
2021-03-28AK: Make Concepts.h and StdLibExtras.h properly alias their own sumbols.Michel Hermier
2021-03-27AK: Add complex number libraryCesar Torres
Useful for diverse algorithms. Also added some tests for it.
2021-03-26AK: Allow assigning a value to a specific index in a JsonArrayTimothy Flynn
2021-03-25AK: Add starts_with to Utf8ViewIdan Horowitz
Unlike String/StringView::starts_with this compares utf8 code points instead of "characters" (bytes), which is important when handling aribtary utf-8 input that could include overlong characters.
2021-03-25AK: Add longer human readable size to string helper functionDavid Isaksson
Wraps the existing AK::human_readable_size function but will always display the bytes in the base unit as well as the shorter string with one decimal. E.g. "14 KiB (14396 bytes)".
2021-03-23LibGUI: Remove one ancient GMENU_DEBUG debug logAndreas Kling
2021-03-23AK: Implement bit_castOleg Sikorskiy
2021-03-21Kernel::CPU: Move headers into common directoryHendiadyoin1
Alot of code is shared between i386/i686/x86 and x86_64 and a lot probably will be used for compatability modes. So we start by moving the headers into one Directory. We will probalby be able to move some cpp files aswell.
2021-03-21AK+LibC: Make %p specifier Architecture IndependentHendiadyoin1
We were using u32 as a pointer representation and not FlatPtr
2021-03-21AK: Fix integer_sequence_generate_arrayHendiadyoin1
It was for some reason Architecture dependent. Now we use size_t instead of unsinged long
2021-03-21AK: Add a Ptr32 type to handle fixed sized pointersHendiadyoin1
This will be used to fix the UHCI Controller, which relies on the pointer-size being 32-bit
2021-03-17AK: Implement terabytes, petabytes, exabytesJean-Baptiste Boric
2021-03-17AK: Add 64 bit methods to JsonValueJean-Baptiste Boric
2021-03-17AK: Move move() into the "std" namespaceAndreas Kling
This makes GCC emit warnings about redundant and pessimizing moves. It also allows static analyzers like clang-tidy to detect common bugs like use-after-move.
2021-03-17Everywhere: Remove pessimizing and redundant move()Andreas Kling
2021-03-17AK: Tests: TestURL: Add port_int_overflow_wrap testBrendan Coles
2021-03-16LibCompress+AK: Dont short-circuit error handling propagationIdan Horowitz
In the case that both the stream and the wrapped substream had errors to be handled only one of the two would be resolved due to boolean short circuiting. this commit ensures both are handled irregardless of one another.
2021-03-15LibCompress+AK: Propagate error handling to wrapped streamsIdan Horowitz
This ensures that when a DeflateCompressor stream is cleared of any errors its underlying wrapped streams (InputBitStream/InputMemoryStream) will be cleared as well and wont fail a VERIFY on destruction.
2021-03-15AK: Make ByteBuffer::slice(0, size()) a freebieAndreas Kling
If you want the whole buffer, we can just give you the buffer itself.
2021-03-13AK: Add fast paths for aligned bit writes in BitOutputStreamIdan Horowitz
If the bit write is aligned (or has been aligned during the write) we can write in multiples of 32/16/8 bits for increased performance.
2021-03-13AK: Store BinaryHeap key-value pairs together for efficient swapsIdan Horowitz
The 2 seperate key and value arrays are replaced with a single struct pair array that allows for a 2x reduction in loads/stores during element swaps in the common case of same-sized keys and values.
2021-03-13AK: Implement minimum BinaryHeapIdan Horowitz
This enables efficient implementations of priority queues, and will also be used in LibCompress for efficient huffman tree generation.