Skip to content

Commit 16c61b4

Browse files
authored
fix (#1174)
* fix * fix * f * fix * fix * fix * fix
1 parent 9897f8a commit 16c61b4

File tree

96 files changed

+343
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+343
-295
lines changed

include/fast_io_core_impl/allocation/adapters.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,13 @@ class generic_allocator_adapter
286286
{
287287
return allocator_type::reallocate_at_least(p, n).ptr;
288288
}
289-
else if constexpr (::fast_io::details::has_reallocate_aligned_impl<alloc>)
289+
else if constexpr (::fast_io::details::has_reallocate_aligned_n_impl<alloc>)
290290
{
291-
return allocator_type::reallocate_aligned_n(p, default_alignment, n);
291+
return allocator_type::reallocate_aligned_n(p, oldn, default_alignment, n);
292292
}
293-
else if constexpr (::fast_io::details::has_reallocate_aligned_at_least_impl<alloc>)
293+
else if constexpr (::fast_io::details::has_reallocate_aligned_n_at_least_impl<alloc>)
294294
{
295-
return allocator_type::reallocate_aligned_n_at_least(p, default_alignment, n).ptr;
295+
return allocator_type::reallocate_aligned_n_at_least(p, oldn, default_alignment, n).ptr;
296296
}
297297
else if constexpr (::fast_io::details::has_reallocate_zero_impl<alloc>)
298298
{
@@ -304,11 +304,11 @@ class generic_allocator_adapter
304304
}
305305
else if constexpr (::fast_io::details::has_reallocate_aligned_zero_impl<alloc>)
306306
{
307-
return allocator_type::reallocate_aligned_zero_n(p, default_alignment, n);
307+
return allocator_type::reallocate_aligned_zero_n(p, oldn, default_alignment, n);
308308
}
309309
else if constexpr (::fast_io::details::has_reallocate_aligned_zero_at_least_impl<alloc>)
310310
{
311-
return allocator_type::reallocate_aligned_zero_n_at_least(p, default_alignment, n).ptr;
311+
return allocator_type::reallocate_aligned_zero_n_at_least(p, oldn, default_alignment, n).ptr;
312312
}
313313
else
314314
{
@@ -683,7 +683,7 @@ class generic_allocator_adapter
683683
}
684684
else if constexpr (::fast_io::details::has_reallocate_aligned_zero_n_impl<alloc>)
685685
{
686-
return allocator_type::reallocate_aligned_zero_n(p, alignment, n).ptr;
686+
return allocator_type::reallocate_aligned_zero_n(p, oldn, alignment, n).ptr;
687687
}
688688
else
689689
{
@@ -981,31 +981,31 @@ class generic_allocator_adapter
981981
{
982982
if constexpr (::fast_io::details::has_reallocate_aligned_n_at_least_impl<alloc>)
983983
{
984-
return allocator_type::reallocate_aligned_n_at_least(p, alignment, n);
984+
return allocator_type::reallocate_aligned_n_at_least(p, oldn, alignment, n);
985985
}
986986
else if constexpr (::fast_io::details::has_reallocate_aligned_at_least_impl<alloc>)
987987
{
988988
return allocator_type::reallocate_aligned_at_least(p, alignment, n);
989989
}
990990
else if constexpr (::fast_io::details::has_reallocate_aligned_zero_n_at_least_impl<alloc>)
991991
{
992-
return allocator_type::reallocate_aligned_zero_n_at_least(p, alignment, n);
992+
return allocator_type::reallocate_aligned_zero_n_at_least(p, oldn, alignment, n);
993993
}
994994
else if constexpr (::fast_io::details::has_reallocate_aligned_zero_at_least_impl<alloc>)
995995
{
996996
return allocator_type::reallocate_aligned_zero_at_least(p, alignment, n);
997997
}
998998
else if constexpr (::fast_io::details::has_reallocate_aligned_impl<alloc>)
999999
{
1000-
return allocator_type::reallocate_aligned_n(p, alignment, n);
1000+
return allocator_type::reallocate_aligned_n(p, oldn, alignment, n);
10011001
}
10021002
else if constexpr (::fast_io::details::has_reallocate_aligned_impl<alloc>)
10031003
{
10041004
return allocator_type::reallocate_aligned(p, alignment, n);
10051005
}
10061006
else if constexpr (::fast_io::details::has_reallocate_aligned_zero_n_impl<alloc>)
10071007
{
1008-
return allocator_type::reallocate_aligned_zero_n(p, alignment, n);
1008+
return allocator_type::reallocate_aligned_zero_n(p, oldn, alignment, n);
10091009
}
10101010
else if constexpr (::fast_io::details::has_reallocate_aligned_zero_impl<alloc>)
10111011
{
@@ -1046,11 +1046,11 @@ class generic_allocator_adapter
10461046
{
10471047
if constexpr (::fast_io::details::has_reallocate_aligned_zero_n_at_least_impl<alloc>)
10481048
{
1049-
return allocator_type::reallocate_aligned_zero_n_at_least(p, alignment, n);
1049+
return allocator_type::reallocate_aligned_zero_n_at_least(p, oldn, alignment, n);
10501050
}
10511051
else if constexpr (::fast_io::details::has_reallocate_aligned_zero_n_impl<alloc>)
10521052
{
1053-
return {allocator_type::reallocate_aligned_zero_n(p, alignment, n), n};
1053+
return {allocator_type::reallocate_aligned_zero_n(p, oldn, alignment, n), n};
10541054
}
10551055
else
10561056
{

include/fast_io_core_impl/allocation/c_malloc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ class c_malloc_allocator
204204
{
205205
return;
206206
}
207+
207208
#if FAST_IO_HAS_BUILTIN(__builtin_free)
208-
__builtin_free
209+
__builtin_free
209210
#else
210211
::std::free
211212
#endif

include/fast_io_core_impl/allocation/linux_kernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class linux_kmalloc_allocator
6060
}
6161
static inline void deallocate(void *p) noexcept
6262
{
63-
if (p == nullptr)
63+
if (p == nullptr) [[unlikely]]
6464
{
6565
return;
6666
}

include/fast_io_core_impl/allocation/mimalloc_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ class mimalloc_allocator
343343

344344
inline static void deallocate_aligned(void *p, ::std::size_t alignment) noexcept
345345
{
346-
if (p == nullptr)
346+
if (p == nullptr) [[unlikely]]
347347
{
348348
return;
349349
}

include/fast_io_core_impl/allocation/nt_rtlheapalloc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ inline void *nt_rtlallocate_heap_handle_common_impl(void *heaphandle, ::std::siz
1919
}
2020
auto p{::fast_io::win32::nt::RtlAllocateHeap(heaphandle, flag, n)};
2121
if (p == nullptr)
22+
#if __has_cpp_attribute(unlikely)
23+
[[unlikely]]
24+
#endif
2225
{
2326
::fast_io::fast_terminate();
2427
}
@@ -108,7 +111,7 @@ class nt_rtlallocateheap_allocator
108111
}
109112
static inline void deallocate(void *addr) noexcept
110113
{
111-
if (addr == nullptr)
114+
if (addr == nullptr) [[unlikely]]
112115
{
113116
return;
114117
}

include/fast_io_core_impl/allocation/win32_heapalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class win32_heapalloc_allocator
164164
}
165165
static inline void deallocate(void *addr) noexcept
166166
{
167-
if (addr == nullptr)
167+
if (addr == nullptr) [[unlikely]]
168168
{
169169
return;
170170
}

include/fast_io_core_impl/allocation/wincrt_malloc_dbg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class wincrt_malloc_dbg_allocator
5858
}
5959
static inline void deallocate(void *p) noexcept
6060
{
61-
if (p == nullptr)
61+
if (p == nullptr) [[unlikely]]
6262
{
6363
return;
6464
}

include/fast_io_core_impl/bitops/rtz.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ inline constexpr ::fast_io::bitops::rtz_result<T> rtz_impl(T n) noexcept
118118
s += b;
119119
n = b ? r : n;
120120

121+
// c1 == d1 == 42949673u
121122
constexpr ::std::uint_least32_t d1{42949673u};
122123
r = ::std::rotr(static_cast<std::uint32_t>(n * d1), 2);
123124
b = r < d1;

include/fast_io_core_impl/buffer_view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct basic_ibuffer_view
1515
template <::std::contiguous_iterator Iter>
1616
requires ::std::same_as<::std::remove_cvref_t<::std::iter_value_t<Iter>>, char_type>
1717
inline constexpr basic_ibuffer_view(Iter first, Iter last) noexcept
18-
: begin_ptr{::std::to_address(first)}, curr_ptr{begin_ptr}, end_ptr{curr_ptr + (last - first)}
18+
: begin_ptr{::std::to_address(first)}, curr_ptr{begin_ptr}, end_ptr{::std::to_address(last)}
1919
{
2020
}
2121
template <::std::ranges::contiguous_range rg>

include/fast_io_core_impl/char_category/char_category_traits.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22

33
namespace fast_io::char_category
44
{

0 commit comments

Comments
 (0)