summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-05-22AK/NumericLimits: Add `lowest()` for floating-point typesJelle Raaijmakers
2021-05-22IntrusiveList: Remove redundant constructorLenny Maiorani
Problem: - The constructor is defined to be the default constructor. Solution: - Let the compiler generate the destructor by setting it to the default.
2021-05-22AK/Vector: Constify find_first_index()Jelle Raaijmakers
2021-05-22AK: Fix Variant construction from lvalue referencesAli Mohammad Pur
Fixes #7371 and appends its test cases.
2021-05-22AK: Remove [[gnu::noinline]] attribute from some variant membersAli Mohammad Pur
These were left-overs from a debugging session :P
2021-05-22AK: Use calculate_base64_encoded_length in encode_base64Idan Horowitz
We were accidentally calling calculate_base64_decoded_length instead, which resulted in extra allocations during the StringBuilder::append calls that can be avoided.
2021-05-21Games: Add HeartsGunnar Beutner
2021-05-21AK: Add Utf8View::iterator_at_byte_offset methodMax Wipfli
This implements a method to get a Utf8CodepointIterator at a specified byte offset.
2021-05-21AK: Add substring methods to Utf8ViewMax Wipfli
This patch implements a Unicode-safe substring method, which can be used when offset and length should be specified in actual characters instead of bytes. This can be used to mitigate issues where a string is split in the middle of a UTF-8 multi-byte character, which leads to invalid UTF-8. Furthermore, it implements to common shorthands for substring methods which take only an offset and return the substring until the end of the string.
2021-05-21AK: Change some argument and return types in Utf8View from int to size_tMax Wipfli
This changes the return type of Utf8View::byte_length and the argument types of substring_view from int to size_t.
2021-05-21Shell: Hide job times behind SHELL_JOB_DEBUG flagAndrew Kaster
2021-05-20LibCore: Let IODevice::can_read_line() buffer until \n or EOFr-paiva
If a line was larger than 1024 bytes or the file ended without a newline character, can_read_line would return false. IODevice::can_read_line() now reads until a newline is found or EOF is reached. fixes #5907
2021-05-20AK: Added contains_in_range to Vectorr-paiva
Vector::contains_in_range() allows the search of an element in a given range on a vector object. Also added testcases for the new Vector method.
2021-05-20AK: Add UnicodeUtils with Unicode-related helper functionsMax Wipfli
This introduces the UnicodeUtils file, which contains helper functions related to Unicode. This is in contrast to StringUtils, whose functions are not directly related to Unicode and are, in theory, encoding-agnostic.
2021-05-20Variant: Remove redundant inline keywordLenny Maiorani
Problem: - `constexpr inline` is redundant because `constexpr` implies `inline`. Solution: - Remove redundancy.
2021-05-20AK: Don't unlink intrusive list elements in the destructorGunnar Beutner
Removing the element from the intrusive linked list might not be safe if doing so requires a lock. Instead this is something the caller should have done so let's verify instead that we're not on any lists.
2021-05-19Bitmap: De-duplicate bitmasksLenny Maiorani
Problem: - Bitmasks are duplicated. - Bitmasks are C-style arrays. Solution: - Move bitmasks to BitmapView.h. - Change C-style arrays to be AK::Array for added safety.
2021-05-19AK: Add String::find_all() and String::count()Maciej Zygmanowski
2021-05-19AK: Add inline storage support for the Function classGunnar Beutner
This allows us to allocate most Function objects on the stack or as part of other objects and gets rid of quite a few allocations.
2021-05-19Everywhere: Add missing includes for <AK/OwnPtr.h>Gunnar Beutner
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to change though. This patch fixes a few build problems that will occur when that change happens.
2021-05-19AK: Allow AK::Variant::visit to return a valueTimothy Flynn
This changes Variant::visit() to forward the value returned by the selected visitor invocation. By perfectly forwarding the returned value, this allows for the visitor to return by value or reference. Note that all provided visitors must return the same type - the compiler will otherwise fail with the message: "inconsistent deduction for auto return type".
2021-05-19Time: Remove static from function local constexpr variableLenny Maiorani
Problem: - Function local `constexpr` variables do not need to be `static`. This consumes memory which is unnecessary and can prevent some optimizations. - C-style arrays are not as safe as AK::Arrays and require the user to specify the length of the array manually. Solution: - Remove `static` keyword. - Change from C-style array for AK::Array.
2021-05-19AK: Make vout() log to debug instead of VERIFY()'ingAli Mohammad Pur
In case the write was to stderr/stdout, and it just so happened to fail because of an issue like "the pty is gone", VERIFY() would end up calling vout() back to write to stderr, which would then fail forever until the stack is exhausted. "Fixes" the issue where the Shell would crash in horrible ways when the terminal is closed.
2021-05-18AK: StringBuilder should prefer to use its inline capacity firstGunnar Beutner
Previously StringBuilder would start allocating an external buffer once the caller has used up more than half of the inline buffer's capacity. Instead we should prefer to use the inline buffer until it is full and only then start to allocate an external buffer.
2021-05-18AK: Implement StringBuilder::append_as_lowercase(char ch)Max Wipfli
This patch adds a convenience method to AK::StringBuilder which converts ASCII uppercase characters to lowercase before appending them.
2021-05-18AK: Add deduction guides to TupleAli Mohammad Pur
2021-05-18AK: Let HashMap export its key and value typesAli Mohammad Pur
2021-05-18LibGfx: Add support for DDS imagesstelar7
2021-05-18AK: Make LexicalPath handle relative paths correctlyGunnar Beutner
Previously LexicalPath would consider "." and ".." as equivalent to "/". This is not true though.
2021-05-18BitmapView: Disable mutations of the underlying BitmapLenny Maiorani
Problem: - `BitmapView` permits changing the underlying `Bitmap`. This violates the idea of a "view" since views are simply overlays which can themselves change but do not change the underlying data. Solution: - Migrate all non-`const` member functions to Bitmap.
2021-05-18AK/PrintfImplementation: Change static constexpr array to function localLenny Maiorani
Problem: - Static variables take memory and can be subject to less optimization. - This static variable is only used in 1 place. Solution: - Move the variable into the function and make it non-static.
2021-05-18AK: Revert removal of StringBuilder::will_append optimizationGunnar Beutner
This was removed as part of the ByteBuffer changes but the allocation optimization is still necessary at least for non-SerenityOS targets where malloc_good_size() isn't supported or returns a small value and causes a whole bunch of unnecessary reallocations.
2021-05-17AK: Sort all the debug macrosLinus Groh
2021-05-17LibWasm: Start implementing a naive bytecode interpreterAli Mohammad Pur
As the parser now flattens out the instructions and inserts synthetic nesting/structured instructions where needed, we can treat the whole thing as a simple parsed bytecode stream. This currently knows how to execute the following instructions: - unreachable - nop - local.get - local.set - {i,f}{32,64}.const - block - loop - if/else - branch / branch_if - i32_add - i32_and/or/xor - i32_ne This also extends the 'wasm' utility to optionally execute the first function in the module with optionally user-supplied arguments.
2021-05-17AK: Include HashTable.h in StringImpl.cppAli Mohammad Pur
This was used without an include, I'm not sure how it didn't break before :P
2021-05-17AK: Include String.h in ScopeLoggerAli Mohammad Pur
2021-05-17Everywhere: Fix a bunch of typosLinus Groh
2021-05-17Revert "BitmapView: Disable mutations of the underlying Bitmap"Andreas Kling
This reverts commit f25209113fcd15df5778938c4accf13c5139d278.
2021-05-17BitmapView: Disable mutations of the underlying BitmapLenny Maiorani
Problem: - `BitmapView` permits changing the underlying `Bitmap`. This violates the idea of a "view" since views are simply overlays which can themselves change but do not change the underlying data. Solution: - Migrate all non-`const` member functions to Bitmap.
2021-05-16AK: Don't read past the end in BitmapView::count_in_range()Andrew Kaster
The current code is factored such that reads to the entirety of the last byte should be dropped. This was relying on the fact that last would be one past the end in that case. Instead of actually reading that byte when it's completely out of bounds of the bitmask, just skip reads that would be invalid. Add more tests to make sure that the behavior is correct for byte aligned reads of byte aligned bitmaps.
2021-05-16AK: Don't call memcpy with null argument in ByteBuffer::copy()Andrew Kaster
This was happening in TestBase64.test_decode, while copying an empty string.
2021-05-16Kernel/Graphics + SystemServer: Support text mode properlyLiav A
As we removed the support of VBE modesetting that was done by GRUB early on boot, we need to determine if we can modeset the resolution with our drivers, and if not, we should enable text mode and ensure that SystemServer knows about it too. Also, SystemServer should first check if there's a framebuffer device node, which is an indication that text mode was not even if it was requested. Then, if it doesn't find it, it should check what boot_mode argument the user specified (in case it's self-test). This way if we try to use bochs-display device (which is not VGA compatible) and request a text mode, it will not honor the request and will continue with graphical mode. Also try to print critical messages with mininum memory allocations possible. In LibVT, We make the implementation flexible for kernel-specific methods that are implemented in ConsoleImpl class.
2021-05-16AK+Userland: Remove nullability feature for the ByteBuffer typeGunnar Beutner
Nobody seems to use this particular feature, in fact there were some bugs which were uncovered by removing operator bool.
2021-05-16AK: Turn ByteBuffer into a value typeGunnar Beutner
Previously ByteBuffer would internally hold a RefPtr to the byte buffer and would behave like a reference type, i.e. copying a ByteBuffer would not create a duplicate byte buffer, but rather two objects which refer to the same internal buffer. This also changes ByteBuffer so that it has some internal capacity much like the Vector<T> type. Unlike Vector<T> however a byte buffer's data may be uninitialized. With this commit ByteBuffer makes use of the kmalloc_good_size() API to pick an optimal allocation size for its internal buffer.
2021-05-16AK+Userland: Fix some compiler warnings and make variables const-refGunnar Beutner
This fixes a few compiler warnings and makes some variables const-ref in preparation for the next commit which changes how ByteBuffer works.
2021-05-16AK+Meta: Add a debug option for SolitaireTimothy Flynn
2021-05-16LibVT: Implement new ANSI escape sequence parserDaniel Bertalan
This commit replaces the former, hand-written parser with a new one that can be generated automatically according to a state change diagram. The new `EscapeSequenceParser` class provides a more ergonomic interface to dealing with escape sequences. This interface has been inspired by Alacritty's [vte library](https://github.com/alacritty/vte/). I tried to avoid changing the application logic inside the `Terminal` class. While this code has not been thoroughly tested, I can't find regressions in the basic command line utilities or `vttest`. `Terminal` now displays nicer debug messages when it encounters an unknown escape sequence. Defensive programming and bounds checks have been added where we access parameters, and as a result, we can now endure 4-5 seconds of `cat /dev/urandom`. :D We generate EscapeSequenceStateMachine.h when building the in-kernel LibVT, and we assume that the file is already in place when the userland library is being built. This will probably cause problems later on, but I can't find a way to do it nicely.
2021-05-16AK+Kernel+LibELF: Remove the need for `IteratorDecision::Continue`Nicholas Baron
By constraining two implementations, the compiler will select the best fitting one. All this will require is duplicating the implementation and simplifying for the `void` case. This constraining also informs both the caller and compiler by passing the callback parameter types as part of the constraint (e.g.: `IterationFunction<int>`). Some `for_each` functions in LibELF only take functions which return `void`. This is a minimal correctness check, as it removes one way for a function to incompletely do something. There seems to be a possible idiom where inside a lambda, a `return;` is the same as `continue;` in a for-loop.
2021-05-15AK+LibC: Implement malloc_good_size() and use it for Vector/HashTableGunnar Beutner
This implements the macOS API malloc_good_size() which returns the true allocation size for a given requested allocation size. This allows us to make use of all the available memory in a malloc chunk. For example, for a malloc request of 35 bytes our malloc would internally use a chunk of size 64, however the remaining 29 bytes would be unused. Knowing the true allocation size allows us to request more usable memory that would otherwise be wasted and make that available for Vector, HashTable and potentially other callers in the future.
2021-05-15AK: Try to avoid String allocation in FlyString(StringView)Andreas Kling
If we're constructing a FlyString from a StringView, and we already have a matching StringImpl in the table, use HashTable::find() to locate the existing string without creating a temporary String.