summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-09-28AK: Eliminate avoidable strlen call in String::matchesIdan Horowitz
We already know the length of these substrings, so there's no need to check their lengths using strlen in the StringView(char*) constructor. This patch also removes an accidental 1-byte OOB read that was left over from when this method received null-terminated char pointers instead of string views, as well removes the unnecessary lambda call (two of the checks were impossible, and this was only called in one place, so we can just inline it)
2021-09-21AK: Introduce ability to default-initialize a VariantBen Wiederhake
I noticed that Variant<Empty, …> is a somewhat common pattern while working on #10080, and this will simplify a few use-cases. :^)
2021-09-20AK: Remove unnecessary include of <new> for non-`__serenity__` buildsAndrew Kaster
We already include `<new>` in AK/kmalloc.h when KERNEL is not defined, which applies to all non-`__serenity__` builds.
2021-09-20AK+LibC: Remove SERENITY_LIBC_BUILD guard around `<initializer_list>`Andrew Kaster
This was required before commit 5f724b6ca1aae3a5a8c7189069649e8a9347cca2 when we were building LibC before libstdc++ headers were available in the sysroot. However as noted in that commit, we never actually needed to be building LibC before libstdc++, so we can go ahead and remove this ancient hack.
2021-09-20AK: Remove unused ifdef for BUILDING_SERENITY_TOOLCHAINAndrew Kaster
The only use of this define was removed in commit 5f724b6ca1aae3a5a8c7189069649e8a9347cca2, over a year ago. The define was there to prevent the LibC build we built before libstdc++ from complaining about missing libgcc symbols. However, as noted in that commit, we never actually needed to build LibC at all.
2021-09-18AK: Inline all the trivial Utf8View functionsAndreas Kling
This improves parsing time on a large chunk of JS by ~3%.
2021-09-18AK: Make Utf8View constructors inline and remove C string constructorAndreas Kling
Using StringView instead of C strings is basically always preferable. The only reason to use a C string is because you are calling a C API.
2021-09-17AK/Vector: Add `Vector::reverse()` methodMustafa Quraish
This reverses the contents of the vector in-place.
2021-09-16AK: Reduce the scope of fraction_string to where it's neededBrian Gianforcaro
pvs-studio flagged this a potential optimization, as we only need to really construct the fraction_string if is_double is true.
2021-09-16AK: Use default constructor/destructor instead of declaring an empty oneBrian Gianforcaro
Default implementations allow for more optimizations. See: https://pvs-studio.com/en/docs/warnings/v832/
2021-09-15AK: Rename the local variable in the TRY() macro to avoid name clashesLinus Groh
"result" is a tad bit too generic to provide a clash-free experience - we found instances in LibJS where this breaks already. Essentially this doesn't work: auto foo = TRY(bar(result)); Because it expands to the following within the TRY() scope: { auto result = bar(result); ... } And that of course fails: error: use of ‘result’ before deduction of ‘auto’ The simple solution here is to use a name that is much less likely to clash with anything used in the expression ("_temporary_result"). :^)
2021-09-14AK: Add an abstraction over multiple disjoint buffersAli Mohammad Pur
DisjointChunks<T> provides a nice interface over multiple sequential Vector<T>'s, allowing the user to iterate over/index into/slice from said buffers as if they were a single contiguous buffer. To work with views on such objects, DisjointSpans<T> is provided, which has the same behaviour but does not own the underlying objects.
2021-09-14AK: Move the path argument of URL::append_path instead of copying itIdan Horowitz
2021-09-14AK: Make URL::m_port an Optional<u16>, Expose raw port getterIdan Horowitz
Our current way of signalling a missing port with m_port == 0 was lacking, as 0 is a valid port number in URLs.
2021-09-14AK: Add URL::cannot_have_a_username_or_password_or_portIdan Horowitz
As defined by the URL specification: https://url.spec.whatwg.org/#cannot-have-a-username-password-port
2021-09-14AK: Change URL::cannot_be_a_base_url, URL::is_valid return type to boolIdan Horowitz
There's no need to return a const reference (8 bytes) when the value is always used as a temporary bool (1 byte).
2021-09-14AK: Accept optional url and state override parameters in URLParserIdan Horowitz
These are required in the specification and used by the web's URL built-in, this commit also removes the Badge<AK::URL> from URLParser to allow other classes that need to call the parser directly like the web's URL built-in to do so.
2021-09-14AK: Add URL::serialize_origin based on HTML's origin definitionIdan Horowitz
2021-09-13AK: Remove unimplemented method `fill_buffer` from `UUID`James Puleo
2021-09-13AK: Make Span::operator==() comply with the ISO C++ idea of operator==Ali Mohammad Pur
This should: - Accept const& on both sides - Not involve implicit conversions on either side otherwise the argument order would be deemed significant, and trip this warning.
2021-09-13AK: Switch Span.h to east-const styleAli Mohammad Pur
2021-09-13AK: Give BumpAllocator a single-block cacheAli Mohammad Pur
This avoid excessive mmap/munmap traffic in normal operation.
2021-09-13AK: Allow RBTree::find_largest_not_above_iterator() to failAli Mohammad Pur
Previously this function would've crashed if the key failed to match any entry.
2021-09-13AK+Kernel: Avoid unescaped control chars in append_escaped_for_json()Ali Mohammad Pur
Otherwise it could produce invalid JSON.
2021-09-13AK: Make traits for NonnullOwnPtr use ptr_hash instead of int_hashAli Mohammad Pur
Otherwise they'd be truncating the pointer in 64-bit builds.
2021-09-13AK: Add secure_zero() implementation so it can be used on all platformsBrian Gianforcaro
Serenity has explicit_bzero() in LibC with the same implementation, however we need to be able to use this from Lagom on all platforms that we support building serenity on. I've implemented it in AK for this reason.
2021-09-12AK+LibCore: Standardize on AK_OS_MACOS instead of __APPLE__Brian Gianforcaro
We use our custom platform definitions in most places, remove the few remaining places we weren't using `AK_OS_MACOS`.
2021-09-12AK: Add the ability to hash the contents of a AK::HashMapBrian Gianforcaro
2021-09-12AK: Escape '"' in escape_html_entitiesPeter Elliott
2021-09-11AK: Replace the mutable String::replace API with an immutable versionIdan Horowitz
This removes the awkward String::replace API which was the only String API which mutated the String and replaces it with a new immutable version that returns a new String with the replacements applied. This also fixes a couple of UAFs that were caused by the use of this API. As an optimization an equivalent StringView::replace API was also added to remove an unnecessary String allocations in the format of: `String { view }.replace(...);`
2021-09-11AK: Make String::count not use strstr and take a StringViewIdan Horowitz
This was needlessly copying StringView arguments, and was also using strstr internally, which meant it was doing a bunch of unnecessary strlen calls on it. This also moves the implementation to StringUtils to allow API consistency between String and StringView.
2021-09-11AK: Forbid creating StringView from temporary FlyStringBen Wiederhake
2021-09-11AK: Forbid creating StringView from temporary ByteBufferBen Wiederhake
2021-09-10Kernel: Add kernelearlyputstr and use it in dbgln in very-early bootIdan Horowitz
This variant of dbgputstr does not lock the global log lock, as it is called before the current or any other processor was initialized, meaning that: A) The $gs base was not setup yet, so we cannot enter into critical sections, and as a result we cannot use SpinLocks B) No other processors may try to print at the same time anyway
2021-09-10AK: Only try and get the Processor::current_id when it was initializedIdan Horowitz
This caused a null pointer dereference on early boot, since the gs_base was not set yet.
2021-09-10AK+Kernel: Reduce the number of template parameters of IntrusiveRBTreeAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-09-10AK+Everywhere: Reduce the number of template parameters of IntrusiveListAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-09-10AK: Mark HashTable::size_in_bytes() as constexprHendiadyoin1
2021-09-10AK: Add OOM safe interface to HashTable/MapHediadyoin1
This adds a new HashSetResult only returned by try_set, to signal allocation failure during setting.
2021-09-10AK: Remove a redundant double find-call in HashMap::ensureIdan Horowitz
If the value was found there's no reason to search for it again.
2021-09-08AK: Add key getter to IntrusiveRedBlackTreeNodeIdan Horowitz
2021-09-08AK: Set IntrusiveRBTree Node key on insertion instead of constructionIdan Horowitz
This makes the API look much nicer.
2021-09-08AK: Make IntrusiveRedBlackTree capable of holding non-raw pointersIdan Horowitz
This is completely based on e4412f1f599bea034dea608b8c7dcc4408d90066 and will allow us to convert some AK::HashMap users in the kernel.
2021-09-08AK: Add note about an internal compile error with Optional in GCC 10.3+sin-ack
This bit me because I accidentally made the destructor for a class which was wrapped in an Optional private. This causes none of the Optional destructors to be able to be deduced, which when combined with concepts causes an internal compile error in GCC 10.3.0+. This commit adds a note here to make sure that future encounters of this bug does not surprise people.
2021-09-07Everywhere: Behaviour => BehaviorAndreas Kling
2021-09-06AK: Use the full name of 'integer_sequence_generate_array' in Variant.hAli Mohammad Pur
c27abaabc449e20e8cffac245d1e2686f94e2ba6 moved this out of the global namespace, but did not qualify its users. While this seems to be fine (sometimes, somehow), let's qualify it to avoid random breakage.
2021-09-06AK: Make Json{Array,Object}Serializer ignore append() return valuesAndreas Kling
This is in preparation for making KBufferBuilder::append() and friends return a KResult. Long-term we should come up with a solution that works for both kernel and userspace clients of the JSON API.
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-09-06Everywhere: Use OOM-safe ByteBuffer APIs where possibleAli Mohammad Pur
If we can easily communicate failure, let's avoid asserting and report failure instead.
2021-09-06AK: Add OOM-safe ByteBuffer::try_{resize,append,ensure_capacity}() APIsAli Mohammad Pur