summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2020-10-17AK+Format: Add outln(FILE*, ...) overload.asynts
This commit also removes a few functions like raw_out and vwarn. If we want to write raw output, we can do this as follows: out("{}", "Hello, World!"); The vout stuff isn't really public API anyways, so no need for another vwarn.
2020-10-17BinarySearch: constexpr supportLenny Maiorani
Problem: - It is not possible to perform a binary search at compile-time because `binary_search` is not `constexpr`-aware. Solution: - Add `constexpr` support.
2020-10-17ntpquery: Don't leak local time, and check origin time in replyNico Weber
This implements the transmit time suggestion in (abandoned?) draft-ietf-ntp-data-minimization. (The other suggestions were already implemented as far as I can tell.)
2020-10-16Span: constexpr supportLenny Maiorani
Problem: - `Span` is not `constexpr` aware. Solution: - Add `constexpr` support for all parts that do not require `reinterpret_cast`. - Modify tests which use the `constexpr` functions.
2020-10-16AK: Tune HashTable load factorAndreas Kling
Double the capacity when used+deleted buckets crosses 60% of capacity. This appears to be a sweet spot for performance based on some ad-hoc testing with test-js. :^)
2020-10-16AK: Add some more checks to the HashMap testAndreas Kling
2020-10-15AK: Redesign HashTable to use closed hashingAndreas Kling
Instead of each hash bucket being a SinglyLinkedList, switch to using closed hashing (open addressing). Buckets are chained together via double hashing (hashing the hash until we find an unused bucket.) This greatly reduces malloc traffic, since each added element no longer allocates a new linked list node. Appears performance neutral on test-js. Can definitely be tuned and could use proper management of load factor, etc.
2020-10-15AK: Improve HashMap tests a little bitAndreas Kling
2020-10-14AK: Don't forward declare abort.asynts
There is no portable way to forward declare abort because the libc implementations disagree on the signature. Originally, I added a __portable_abort function with a "portable" signature which just called abort. But I really don't like it and just including <stdlib.h> is simpler. Note that the headers we include in <AK/TestSuite.h> are no longer commutative now, we have to include <stdlib.h> before anything else.
2020-10-13Base64: Pre-allocate size of input and outputLenny Maiorani
Problem: - Output of decode and encode grow as the decode and encode happen. This is inefficient because a large size will require many reallocations. - `const` qualifiers are missing on variables which are not intended to change. Solution: - Since the size of the decoded or encoded message is known prior to starting, calculate the size and set the output to that size immediately. All appends will not incur the reallocation overhead. - Add `const` qualifiers to show intent.
2020-10-13Use new format functions in remaining DevTools. (#3755)Paul Scharnofske
* AK: Add formatter for JsonValue. * Inspector: Use new format functions. * Profiler: Use new format functions. * UserspaceEmulator: Use new format functions.
2020-10-13Base64: constexpr initialization of alphabet and lookup tableLenny Maiorani
Problem: - The Base64 alphabet and lookup table are initialized at run-time. This results in an initial start-up cost as well as a boolean evaluation and branch every time the function is called. Solution: - Provide `constexpr` functions which initialize the alphabet and lookup table at compile-time. These can be called and assigned to a `constexpr` variable so that there is no run-time cost associated with the initialization or lookup.
2020-10-12AK: Add SourceGenerator class.asynts
2020-10-09AK: Add formatter for LexcialPath.asynts
2020-10-09AK+Format: Remove new_dbg(dbg) and raw_dbg.asynts
We are adding the process name as prefix and a newline as suffix to any message written to debug. Thus, the following doesn't make any sense: for (u8 byte : bytes) dbg("{:02x} ", byte); dbgln(); Which function call would put the prefix? This doesn't make any sense, thus these functions must go. The example above could be converted to: StringBuilder builder; for (u8 byte : bytes) builder.appendff("{:02x} ", byte); dbgln("{}", builder.build());
2020-10-08Endian: constexpr constructors and conversion operatorsLenny Maiorani
Problem: - Constructors and conversion operators are not `constexpr`, but they can be. - `constexpr` is needed here so that other classes can add `constexpr` evaluation. Solution: - Add the `constexpr` keyword to the constructors and conversion operators. - Add `static_assert` tests which ensure the capability works.
2020-10-08AK: Make StringView hashableMatthew Olsson
2020-10-08AK: Use new format functions.asynts
2020-10-08AK: Add formatter for StringImpl.asynts
2020-10-08AK+Format: Make it possible to format characters as integers.asynts
2020-10-08AK+Format: Add SFINAE wrapper 'FormatIfSupported'.asynts
2020-10-08AK+Format: Add overloads with const char* for outln, warnln and dbgln.asynts
This makes it possible to forward declare 'warnln' in TestSuite.h.
2020-10-08AK+Format: Add overloads without arguments to outln, warnln and dbgln.asynts
2020-10-08AK+Format: Use pointer mode for pointers by default.asynts
2020-10-08VariadicFormatParams: Use initialized data to create parent classLenny Maiorani
Problem: - m_data is being passed to the constructor of the parent class before it is initialized. This is not really a problem because the compiler knows the location and it is only a span being constructed, but it triggers a warning in clang for use-before-init. Solution: - Initialize using a default constructed array and then overwrite it inside the constructor after the member is initialized.
2020-10-08Formatter: Remove extraneous char definitionLenny Maiorani
Formatter is specialized in the header file. The definition in the implementation file is extraneous and has no effect. Simply removing it so that there is no confusion.
2020-10-06AK: Make Vector::remove_first_matching() signal if anything was removedAndreas Kling
2020-10-06AK: Use StringImpl::operator== in FlyStringAndreas Kling
2020-10-06IRCClient: Use new format functions.asynts
2020-10-06AK+Format: Make it possible to format string literals as pointers.asynts
String literals are just pointers to a constant character. It should be possible to format them as such. (The default is to print them as strings still.)
2020-10-06AK+Format: Exclude prefix from width calculation.asynts
When we write the format specifier '{:#08x}' we are asking for eight significant digits, zero padding and the prefix '0x'. However, previously we got only six significant digits because the prefix counted towards the width. (The number '8' here is the total width and not the number of significant digits.) Both fmtlib and printf shared this behaviour. However, I am introducing a special case here because when we do zero padding we really only care about the digits and not the width. Notice that zero padding is a special case anyways, because zero padding goes after the prefix as opposed to any other padding which goes before it.
2020-10-06AK: check fractional string has_value() in JsonParserTucker Polomik
Resolves #3670
2020-10-05AK: Move StringImpl::operator== implementation into StringImplNico Weber
2020-10-05AK: Add formatter for NonnullRefPtr<T>.asynts
2020-10-04LibIPC: Make IPC::encode() and ::decode() fail at compiletime when usedAnotherTest
This would previously fail at runtime, and it would have zero indication of what exactly went wrong. Also adds `AK::DependentFalse<Ts...>', which is a...dependent false.
2020-10-04AK: Make the return type of dbgputstr consistent.asynts
2020-10-04AK: Don't add newline for outf/dbgf/warnf.asynts
In the future all (normal) output should be written by any of the following functions: out (currently called new_out) outln dbg (currently called new_dbg) dbgln warn (currently called new_warn) warnln However, there are still a ton of uses of the old out/warn/dbg in the code base so the new functions are called new_out/new_warn/new_dbg. I am going to rename them as soon as all the other usages are gone (this might take a while.) I also added raw_out/raw_dbg/raw_warn which don't do any escaping, this should be useful if no formatting is required and if the input contains tons of curly braces. (I am not entirely sure if this function will stay, but I am adding it for now.)
2020-10-04AK: Add Formatter for FlyString :^)Andreas Kling
2020-10-04AK: Add formatter for URL.asynts
2020-10-04AK: Add special formatter for char.asynts
When we format a character we want to put the ascii value and not the decimal value. The old behaviour can be obtained with '{:d}'.
2020-10-03AK: Replace a write_or_error call with write.asynts
Implicit conversions suck...
2020-10-03AK: Make Buffered<T> non-copyable.asynts
2020-10-03AK: Add missing Bytes::slice call in Buffered<T>.asynts
2020-10-03Everywhere: Fix more typosLinus Groh
2020-10-02AK+Format: Do some housekeeping in the format implementation.asynts
2020-10-02AK: Add trivial structure validation to SharedBufferTom
If we're sharing buffers, we only want to share trivial structures as anything else could potentially share internal pointers, which most likely is going to cause problems due to different address spaces. Fix the GUI::SystemTheme structure, which was not trivial, which is now caught at compile time. Fixes #3650
2020-10-02AK: Add is_trivial and is_trivially_copyableTom
2020-10-02AK: Add formatter for pointer types.asynts
2020-10-02AK: Add formatter for boolean values.asynts
2020-09-29AK+Format: Add support for integer to character casts.asynts
Now the following is possible: outf("{:c}", 75); // K