Age | Commit message (Collapse) | Author |
|
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)
|
|
I noticed that Variant<Empty, …> is a somewhat common pattern while
working on #10080, and this will simplify a few use-cases. :^)
|
|
We already include `<new>` in AK/kmalloc.h when KERNEL is not defined,
which applies to all non-`__serenity__` builds.
|
|
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.
|
|
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.
|
|
This improves parsing time on a large chunk of JS by ~3%.
|
|
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.
|
|
This reverses the contents of the vector in-place.
|
|
pvs-studio flagged this a potential optimization, as we only
need to really construct the fraction_string if is_double is
true.
|
|
Default implementations allow for more optimizations.
See: https://pvs-studio.com/en/docs/warnings/v832/
|
|
"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"). :^)
|
|
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.
|
|
|
|
Our current way of signalling a missing port with m_port == 0 was
lacking, as 0 is a valid port number in URLs.
|
|
As defined by the URL specification:
https://url.spec.whatwg.org/#cannot-have-a-username-password-port
|
|
There's no need to return a const reference (8 bytes) when the value is
always used as a temporary bool (1 byte).
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
This avoid excessive mmap/munmap traffic in normal operation.
|
|
Previously this function would've crashed if the key failed to match any
entry.
|
|
Otherwise it could produce invalid JSON.
|
|
Otherwise they'd be truncating the pointer in 64-bit builds.
|
|
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.
|
|
We use our custom platform definitions in most places, remove
the few remaining places we weren't using `AK_OS_MACOS`.
|
|
|
|
|
|
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(...);`
|
|
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.
|
|
|
|
|
|
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
|
|
This caused a null pointer dereference on early boot, since the gs_base
was not set yet.
|
|
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
|
|
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
|
|
|
|
This adds a new HashSetResult only returned by try_set, to signal
allocation failure during setting.
|
|
If the value was found there's no reason to search for it again.
|
|
|
|
This makes the API look much nicer.
|
|
This is completely based on e4412f1f599bea034dea608b8c7dcc4408d90066
and will allow us to convert some AK::HashMap users in the kernel.
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
|
|
If we can easily communicate failure, let's avoid asserting and report
failure instead.
|
|
|