@@ -1956,21 +1956,47 @@ class deque FAST_IO_TRIVIALLY_RELOCATABLE_IF_ELIGIBLE
19561956 inline constexpr insert_range_result insert_range_impl (size_type pos, R &&rg, size_type old_size) noexcept (::std::is_nothrow_constructible_v<value_type, ::std::ranges::range_value_t <R>>)
19571957 {
19581958#if 0
1959- size_type const halfold_size{old_size >> 1u};
19601959 if constexpr(::std::ranges::sized_range<R>)
19611960 {
19621961 size_type const rgsize{::std::ranges::size(rg)};
1962+ size_type const half_size{old_size >> 1u};
1963+ if (pos < half_size)
1964+ {
1965+
1966+ }
1967+ else
1968+ {
1969+ }
19631970 }
19641971 else
19651972#endif
19661973 {
1967- this ->append_range (rg);
1968- auto bg{this ->begin ()};
1969- iterator rotfirst = bg + pos;
1970- iterator rotmid = bg + old_size;
1971- iterator rotlast = this ->end ();
1974+ size_type const quarterold_size{old_size >> 2u };
1975+ size_type retpos;
1976+ iterator retit, rotfirst, rotmid, rotlast;
1977+ if (pos < quarterold_size)
1978+ {
1979+ this ->prepend_range (rg);
1980+ size_type const new_size{this ->size ()};
1981+ size_type const inserted{new_size - old_size};
1982+ auto bg{this ->begin ()};
1983+ size_type newpos{pos + inserted};
1984+ rotfirst = bg;
1985+ rotmid = bg + inserted;
1986+ retpos = newpos;
1987+ retit = rotlast = bg + newpos;
1988+ }
1989+ else
1990+ {
1991+ this ->append_range (rg);
1992+ auto bg{this ->begin ()};
1993+ rotfirst = retit = bg + pos;
1994+ rotmid = bg + old_size;
1995+ rotlast = this ->end ();
1996+ retpos = pos;
1997+ }
19721998 ::fast_io::containers::rotate_for_fast_io_deque (rotfirst, rotmid, rotlast);
1973- return {pos, rotfirst };
1999+ return {retpos, retit };
19742000 }
19752001 }
19762002
0 commit comments