Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed Oct 25, 2023
1 parent 099806f commit 243dbcb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ namespace to_string_n{
aret.pre_alloc_before_begin(info_threshold);
}
if constexpr(is_big_type<T>){
//大整数类型可以通过分治法来提高效率
constexpr auto partition_method_threshold=max(type_info<size_t>);
if(num > partition_method_threshold){
if(num.is_safe_convert_to<size_t>())
return to_string(num.convert_to<size_t>());
else{
//大整数类型可以通过分治法来提高效率
T base{radix};
size_t len=1;//余数部分要补的前导0个数
//计算分割点
Expand All @@ -168,11 +169,9 @@ namespace to_string_n{
base *= base;
}
//算出分割后的高位和低位
auto [high,low] = divmod(num, base);
auto [high,low] = divmod(move(num),move(base));
return to_string(move(high)) + to_string(move(low)).pad_left(_repres.get_char(0), len);
}
else
return to_string(num.convert_to<size_t>());
}
else{
push_and_disable_msvc_warning(4244);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,11 @@ struct end_apply_string_data_t final:base_string_data_t<char_T>,instance_struct<
while(type_info<this_t> == typeid(*_to) && _to->is_unique()){
//合并重复的end_apply_string_data_t以防树状结构过深
const auto p=down_cast<this_t*>(_to.get());
const auto p_begin=(const char_T*)(p->_m.begin());
const auto p_size=p->_used_size;
if(_m.size()-_used_size>=p_size)
copy_assign[p_size](note::from<const char_T*>(p_begin),note::to<char_T*>(_m.data()+_used_size));
else{
const auto size_now=this->get_size();
const auto size_new=get_next_gold_size_to_resize_for_array(size_now);
_m.insert_with_resize(_used_size,p_size,p_begin,size_new);
}
discard=p->apply_str_to_end(string_view_t(_m.begin(),_used_size));
_used_size=p->_used_size;
_to_size=p->_to_size;
_used_size+=p_size;
_to=p->_to;
_m=move(p->_m);
_to=move(p->_to);
}
}
void self_changed()noexcept{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,11 @@ struct head_apply_string_data_t final:base_string_data_t<char_T>,instance_struct
while(type_info<this_t> == typeid(*_to) && _to->is_unique()){
//合并重复的head_apply_string_data_t以防树状结构过深
const auto p=down_cast<this_t*>(_to.get());
const auto p_size=p->_used_size;
const auto p_begin=(const char_T*)(p->_m.end())-p_size;
const auto this_begin=_m.end()-_used_size;
const auto pos=_m.size()-_used_size;
if(pos>=p_size)
copy_assign[p_size](note::from<const char_T*>(p_begin),note::to<char_T*>(this_begin-p_size));
else{
const auto size_now=this->get_size();
const auto size_new=get_next_gold_size_to_resize_for_array(size_now);
_m.insert_with_forward_resize(pos,p_size,p_begin,size_new);
}
discard=p->apply_str_to_begin(string_view_t{(char_T*)_m.end()-_used_size,_used_size});
_used_size=p->_used_size;
_to_size=p->_to_size;
_used_size+=p_size;
_to=p->_to;
_m=move(p->_m);
_to=move(p->_to);
}
}
void self_changed()noexcept{
Expand Down

0 comments on commit 243dbcb

Please sign in to comment.