mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:47:34 +00:00
AK: Remove try_
prefix from FixedArray creation functions
This commit is contained in:
parent
909c2a73c4
commit
9c08bb9555
26 changed files with 57 additions and 59 deletions
|
@ -226,12 +226,10 @@ FixedArray<T> shatter_chunk(FixedArray<T>& source_chunk, size_t start, size_t sl
|
|||
if constexpr (IsTriviallyConstructible<T>) {
|
||||
TypedTransfer<T>::move(new_chunk.data(), wanted_slice.data(), wanted_slice.size());
|
||||
} else {
|
||||
// FIXME: propagate errors
|
||||
auto copied_chunk = MUST(FixedArray<T>::try_create(wanted_slice));
|
||||
auto copied_chunk = FixedArray<T>::create(wanted_slice).release_value_but_fixme_should_propagate_errors();
|
||||
new_chunk.swap(copied_chunk);
|
||||
}
|
||||
// FIXME: propagate errors
|
||||
auto rest_of_chunk = MUST(FixedArray<T>::try_create(source_chunk.span().slice(start)));
|
||||
auto rest_of_chunk = FixedArray<T>::create(source_chunk.span().slice(start)).release_value_but_fixme_should_propagate_errors();
|
||||
source_chunk.swap(rest_of_chunk);
|
||||
return new_chunk;
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ class FixedArray {
|
|||
public:
|
||||
FixedArray() = default;
|
||||
|
||||
static ErrorOr<FixedArray<T>> try_create(std::initializer_list<T> initializer)
|
||||
static ErrorOr<FixedArray<T>> create(std::initializer_list<T> initializer)
|
||||
{
|
||||
auto array = TRY(try_create(initializer.size()));
|
||||
auto array = TRY(create(initializer.size()));
|
||||
auto it = initializer.begin();
|
||||
for (size_t i = 0; i < array.size(); ++i) {
|
||||
array[i] = move(*it);
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
return array;
|
||||
}
|
||||
|
||||
static ErrorOr<FixedArray<T>> try_create(size_t size)
|
||||
static ErrorOr<FixedArray<T>> create(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return FixedArray<T>();
|
||||
|
@ -48,17 +48,17 @@ public:
|
|||
|
||||
static FixedArray<T> must_create_but_fixme_should_propagate_errors(size_t size)
|
||||
{
|
||||
return MUST(try_create(size));
|
||||
return MUST(create(size));
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
static ErrorOr<FixedArray<T>> try_create(T (&&array)[N])
|
||||
static ErrorOr<FixedArray<T>> create(T (&&array)[N])
|
||||
{
|
||||
return try_create(Span(array, N));
|
||||
return create(Span(array, N));
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
static ErrorOr<FixedArray<T>> try_create(Span<U> span)
|
||||
static ErrorOr<FixedArray<T>> create(Span<U> span)
|
||||
{
|
||||
if (span.size() == 0)
|
||||
return FixedArray<T>();
|
||||
|
@ -71,9 +71,9 @@ public:
|
|||
return FixedArray<T>(new_storage);
|
||||
}
|
||||
|
||||
ErrorOr<FixedArray<T>> try_clone() const
|
||||
ErrorOr<FixedArray<T>> clone() const
|
||||
{
|
||||
return try_create(span());
|
||||
return create(span());
|
||||
}
|
||||
|
||||
static size_t storage_allocation_size(size_t size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue