mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-08 20:50:16 +00:00
Some Fix.
This commit is contained in:
parent
82655d46c9
commit
06a3acb83d
@ -87,6 +87,7 @@ struct array {
|
||||
|
||||
template <bool may_alias = false, typename T>
|
||||
void uninitialized_copy_n(const T* src, int n, T* dest) {
|
||||
if(n == 0) return;
|
||||
if constexpr(std::is_trivially_copyable_v<T>) {
|
||||
if constexpr(may_alias) {
|
||||
std::memmove(dest, src, sizeof(T) * n);
|
||||
@ -102,6 +103,7 @@ void uninitialized_copy_n(const T* src, int n, T* dest) {
|
||||
|
||||
template <bool may_alias = false, bool backward = false, typename T>
|
||||
void uninitialized_relocate_n(T* src, int n, T* dest) {
|
||||
if(n == 0) return;
|
||||
if constexpr(is_trivially_relocatable_v<T>) {
|
||||
if constexpr(may_alias) {
|
||||
std::memmove(dest, src, sizeof(T) * n);
|
||||
@ -188,6 +190,7 @@ struct vector {
|
||||
T* _grow(int cap) {
|
||||
if(cap < 4) cap = 4; // minimum capacity
|
||||
if(cap <= capacity()) return _data;
|
||||
_capacity = cap;
|
||||
return (T*)std::malloc(sizeof(T) * cap);
|
||||
}
|
||||
|
||||
@ -196,7 +199,6 @@ struct vector {
|
||||
uninitialized_relocate_n(_data, _size, new_data);
|
||||
if(_data) std::free(_data);
|
||||
_data = new_data;
|
||||
_capacity = cap;
|
||||
}
|
||||
|
||||
void resize(int size) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user