summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2023-01-14AK: Add an optional starting offset to `CircularBuffer::offset_of`Lucas CHOLLET
This parameter allows to start searching after an offset. For example, to resume a search. It is unfortunately a breaking change in API so this patch also modifies one user and one test.
2023-01-14AK: Default move operators for `CircularBuffer`Lucas CHOLLET
The previously defined operator was swap-based. With the defaulted implementation, both integers are now copied, but it doesn't matter as only the `ByteBuffer` allocates memory (i.e. non-null integers values won't affect the destruction).
2023-01-14AK+Tests: Make CaseInsensitiveStringViewTraits work with HashMap againBen Wiederhake
2023-01-14AK: Remove `CircularDuplexStream`Tim Schumacher
2023-01-14AK: Add StringBuilder::try_join()MacDue
This is a failable version of StringBuilder::join().
2023-01-13AK: Add `CircularBuffer::read_with_seekback`Tim Schumacher
2023-01-13AK+Everywhere: Disallow returning a reference from a fallible expressionTimothy Flynn
This will silently make a copy. Rather than masking this behavior, let's explicitly disallow it.
2023-01-13AK: Add support for "debug only" formattersMacDue
These are formatters that can only be used with debug print functions, such as dbgln(). Currently this is limited to Formatter<ErrorOr<T>>. With this you can still debug log ErrorOr values (good for debugging), but trying to use them in any String::formatted() call will fail (which prevents .to_string() errors with the new failable strings being ignored). You make a formatter debug only by adding a constexpr method like: static constexpr bool is_debug_only() { return true; }
2023-01-13AK: Don't inherit Formatter<ErrorOr<T>> for Formatter<IPv6Address>MacDue
2023-01-13AK: Don't inherit Formatter<ErrorOr<T>> for Formatter<IPv4Address>MacDue
2023-01-12AK: Fix ignored .to_string() errors in IPv6AddressMacDue
2023-01-12AK: Fix ignored .to_string() errors in IPv4AddressMacDue
2023-01-12AK: Implement FlyString for the new String classTimothy Flynn
This implements a FlyString that will de-duplicate String instances. The FlyString will store the raw encoded data of the String instance: If the String is a short string, FlyString holds the String::ShortString bytes; otherwise FlyString holds a pointer to the Detail::StringData. FlyString itself does not know about String's storage or how to refcount its Detail::StringData. It defers to String to implement these details.
2023-01-10AK+LibWeb: Move decode forgiving base64 under Web::Infra namespaceArda Cinar
Since the forgiving base64 is part of the web infra standard
2023-01-10AK: Expose Base64 tables from Base64.hArda Cinar
This change is necessary to move the forgiving base64 decoder to LibWeb
2023-01-10AK: Add Span::first()MacDue
The missing sibling to Span::last()!
2023-01-09AK+LibUnicode: Provide Unicode-aware String case transformationsTimothy Flynn
Since AK can't refer to LibUnicode directly, the strategy here is that if you need case transformations, you can link LibUnicode and receive them. If you try to use either of these methods without linking it, then you'll of course get a linker error (note we don't do any fallbacks to e.g. ASCII case transformations). If you don't need these methods, you don't have to link LibUnicode.
2023-01-09AK+Everywhere: Rename FlyString to DeprecatedFlyStringTimothy Flynn
DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so let's rename it to A) match the name of DeprecatedString, B) write a new FlyString class that is tied to String.
2023-01-09AK: Add Utf16View::to_utf8 to convert the view to a UTF-8 AK::StringTimothy Flynn
2023-01-09AK+Everywhere: Rename Utf16View::to_utf8 to to_deprecated_stringTimothy Flynn
A subsequent commit will add to_utf8 back to create an AK::String.
2023-01-09AK: Reorder AK/Math after the removal of i686Hendiadyoin1
Without i686 we can remove some implementations for sqrt and round_to.
2023-01-08AK+Everywhere: Make UTF-16 to UTF-8 converter fallibleTimothy Flynn
This could fail to allocate the underlying storage needed to store the UTF-8 data. Propagate this error.
2023-01-08AK+Everywhere: Make UTF-8 and UTF-32 to UTF-16 converters fallibleTimothy Flynn
These could fail to allocate the underlying storage needed to store the UTF-16 data. Propagate these errors.
2023-01-08AK+LibJS+LibRegex: Define an alias for UTF-16 string data storageTimothy Flynn
Instead of writing out "Vector<u16, 1>" everywhere, let's have a name for it.
2023-01-08AK: Make StringBuilder::try_append_code_point actually fallibleTimothy Flynn
It currently uses the non-fallible `append` method to append each UTF-8 encoded byte of the code point.
2023-01-07Everywhere: Remove "LibC/" includes, add lint-rule against itBen Wiederhake
2023-01-07AK: Restrict include of LibC headerBen Wiederhake
2023-01-07AK: Reimplement DistinctNumeric comparison operators using operator<=>Andrew Kaster
Unlike what the class comment says, it's actually valid to return int from this operator and treat it like a "normal" C-like compare method.
2023-01-07AK: Reimplement comparisons on AK::Time using operator<=>Andrew Kaster
This allows us to make all comparision operators on the class constexpr without pulling in a bunch of boilerplate. We don't use the `<compare>` header because it doesn't compile in the main serenity cross-build due to the include paths to LibC being incompatible with how libc++ expects them to be for clang builds.
2023-01-07AK: Remove global free function comparison operators for timespecAndrew Kaster
No code was using these, so let's just delete them. They pollute the lookup for every single comparison operator in the project.
2023-01-07AK: Add user defined literals for Time for ns, us, ms, and secAndrew Kaster
We can use these to simplify Time constants throughout the codebase, turning Time::from_milliseconds(10) into 10_ms, for example.
2023-01-07AK: Make `Statistics::median` return a mean for an even number of valuesStaubfinger
The previous implementation of Statistics::median() was slightly incorrect with an even number of elements since in those cases it needs to be the arithmetic mean of the two elements that share the middle position.
2023-01-06AK: Use base URL when the specified URL is emptyThiago Henrique Hupner
2023-01-06AK: Support fixed point formatting to print real numbersLucas CHOLLET
2023-01-06AK: Rename `StandardFormatter::Mode::Float` => `FixedPoint`Lucas CHOLLET
2023-01-06AK: Export `adopt_nonnull_ref_or_enomem` to the global namespaceSam Atkins
2023-01-06AK: Fix typo in -= operator of DistinctNumericAliaksandr Kalenik
2023-01-02Everywhere: Remove unused includes of AK/Memory.hBen Wiederhake
These instances were detected by searching for files that include AK/Memory.h, but don't match the regex: \\b(fast_u32_copy|fast_u32_fill|secure_zero|timing_safe_compare)\\b This regex is pessimistic, so there might be more files that don't actually use any memory function. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Remove unused includes of LibC/stdlib.hBen Wiederhake
These instances were detected by searching for files that include stdlib.h, but don't match the regex: \\b(_abort|abort|abs|aligned_alloc|arc4random|arc4random_buf|arc4random_ uniform|atexit|atof|atoi|atol|atoll|bsearch|calloc|clearenv|div|div_t|ex it|_Exit|EXIT_FAILURE|EXIT_SUCCESS|free|getenv|getprogname|grantpt|labs| ldiv|ldiv_t|llabs|lldiv|lldiv_t|malloc|malloc_good_size|malloc_size|mble n|mbstowcs|mbtowc|mkdtemp|mkstemp|mkstemps|mktemp|posix_memalign|posix_o penpt|ptsname|ptsname_r|putenv|qsort|qsort_r|rand|RAND_MAX|random|reallo c|realpath|secure_getenv|serenity_dump_malloc_stats|serenity_setenv|sete nv|setprogname|srand|srandom|strtod|strtof|strtol|strtold|strtoll|strtou l|strtoull|system|unlockpt|unsetenv|wcstombs|wctomb)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use anything from the stdlib. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Remove unused includes of AK/Concepts.hBen Wiederhake
These instances were detected by searching for files that include AK/Concepts.h, but don't match the regex: \\b(AnyString|Arithmetic|ArrayLike|DerivedFrom|Enum|FallibleFunction|Flo atingPoint|Fundamental|HashCompatible|Indexable|Integral|IterableContain er|IteratorFunction|IteratorPairWith|OneOf|OneOfIgnoringCV|SameAs|Signed |SpecializationOf|Unsigned|VoidFunction)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use any concepts. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Remove unused includes of AK/StdLibExtras.hBen Wiederhake
These instances were detected by searching for files that include AK/StdLibExtras.h, but don't match the regex: \\b(abs|AK_REPLACED_STD_NAMESPACE|array_size|ceil_div|clamp|exchange|for ward|is_constant_evaluated|is_power_of_two|max|min|mix|move|_RawPtr|RawP tr|round_up_to_power_of_two|swap|to_underlying)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use any "extra stdlib" functions. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Remove unused includes of AK/Format.hBen Wiederhake
These instances were detected by searching for files that include AK/Format.h, but don't match the regex: \\b(CheckedFormatString|critical_dmesgln|dbgln|dbgln_if|dmesgln|FormatBu ilder|__FormatIfSupported|FormatIfSupported|FormatParser|FormatString|Fo rmattable|Formatter|__format_value|HasFormatter|max_format_arguments|out |outln|set_debug_enabled|StandardFormatter|TypeErasedFormatParams|TypeEr asedParameter|VariadicFormatParams|v_critical_dmesgln|vdbgln|vdmesgln|vf ormat|vout|warn|warnln|warnln_if)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use any formatting functions. Observe that this revealed that Userland/Libraries/LibC/signal.cpp is missing an include. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Kernel: Turn lock ranks into template parameterskleines Filmröllchen
This step would ideally not have been necessary (increases amount of refactoring and templates necessary, which in turn increases build times), but it gives us a couple of nice properties: - SpinlockProtected inside Singleton (a very common combination) can now obtain any lock rank just via the template parameter. It was not previously possible to do this with SingletonInstanceCreator magic. - SpinlockProtected's lock rank is now mandatory; this is the majority of cases and allows us to see where we're still missing proper ranks. - The type already informs us what lock rank a lock has, which aids code readability and (possibly, if gdb cooperates) lock mismatch debugging. - The rank of a lock can no longer be dynamic, which is not something we wanted in the first place (or made use of). Locks randomly changing their rank sounds like a disaster waiting to happen. - In some places, we might be able to statically check that locks are taken in the right order (with the right lock rank checking implementation) as rank information is fully statically known. This refactoring even more exposes the fact that Mutex has no lock rank capabilites, which is not fixed here.
2023-01-02AK+Kernel: Eliminate UB (signed overflow) from days_since_epochBen Wiederhake
2023-01-02AK+Tests: Replace years_to_days_since_epoch by near-instant functionBen Wiederhake
This solves half the problem of #12729. Note that the inverse function time_to_tm() in LibC/time.cpp still uses a slow for-loop. See also #13138
2023-01-02AK: Combine SinglyLinkedList and SinglyLinkedListWithCountLenny Maiorani
Using policy based design `SinglyLinkedList` and `SinglyLinkedListWithCount` can be combined into one class which takes a policy to determine how to keep track of the size of the list. The default policy is to use list iteration to count the items in the list each time. The `WithCount` form is a different policy which tracks the size, but comes with the overhead of storing the count and incrementing/decrementing on each modification. This model is extensible to have other forms of counting by implementing only a new policy instead of implementing a totally new type.
2023-01-02AK: Add an option to format numbers with 1000 based unitsArda Cinar
Instead of only allowing 1024-based units.
2023-01-02AK: Make sure no overflow occurs in number_string_with_one_decimalArda Cinar
A possible integer overflow might have occured inside the function in case (number % unit) * 10 did not fit into a u64. So it is verified that this does not happen at the beginning of the function.
2023-01-02AK: Add a human_readable_quantity helper to NumberFormat.hArda Cinar
This can be used for displaying large quantities that are not measured in bytes in a more human-readable format.
2023-01-02AK: Move the functions in NumberFormat.h out of lineArda Cinar