diff --git a/include/pocketpy/common/str.h b/include/pocketpy/common/str.h index 7673948a..7fb2ca6b 100644 --- a/include/pocketpy/common/str.h +++ b/include/pocketpy/common/str.h @@ -56,8 +56,8 @@ int pkpy_Str__unicode_index_to_byte(const pkpy_Str* self, int i); int pkpy_Str__byte_index_to_unicode(const pkpy_Str* self, int n); int pkpy_Str__index(const pkpy_Str* self, const pkpy_Str* sub, int start); int pkpy_Str__count(const pkpy_Str* self, const pkpy_Str* sub); -c11_array/* T=c11_string */ pkpy_Str__split(const pkpy_Str* self, char sep); -c11_array/* T=c11_string */ pkpy_Str__split2(const pkpy_Str* self, const pkpy_Str* sep); +c11_vector/* T=c11_string */ pkpy_Str__split(const pkpy_Str* self, char sep); +c11_vector/* T=c11_string */ pkpy_Str__split2(const pkpy_Str* self, const pkpy_Str* sep); #ifdef __cplusplus } diff --git a/include/pocketpy/common/str.hpp b/include/pocketpy/common/str.hpp index 414d3f5a..ed0f7004 100644 --- a/include/pocketpy/common/str.hpp +++ b/include/pocketpy/common/str.hpp @@ -192,24 +192,24 @@ struct Str: pkpy_Str { } vector split(const Str& sep) const{ - c11_array/* T=c11_string */ res = pkpy_Str__split2(this, &sep); + c11_vector/* T=c11_string */ res = pkpy_Str__split2(this, &sep); vector retval(res.count); for(int i = 0; i < res.count; i++){ c11_string tmp = c11__getitem(c11_string, &res, i); retval[i] = std::string_view(tmp.data, tmp.size); } - c11_array__dtor(&res); + c11_vector__dtor(&res); return retval; } vector split(char sep) const{ - c11_array/* T=c11_string */ res = pkpy_Str__split(this, sep); + c11_vector/* T=c11_string */ res = pkpy_Str__split(this, sep); vector retval(res.count); for(int i = 0; i < res.count; i++){ c11_string tmp = c11__getitem(c11_string, &res, i); retval[i] = std::string_view(tmp.data, tmp.size); } - c11_array__dtor(&res); + c11_vector__dtor(&res); return retval; } diff --git a/include/pocketpy/common/vector.h b/include/pocketpy/common/vector.h index 4cb99c25..0c5d0bb7 100644 --- a/include/pocketpy/common/vector.h +++ b/include/pocketpy/common/vector.h @@ -27,7 +27,6 @@ void c11_vector__dtor(c11_vector* self); c11_vector c11_vector__copy(const c11_vector* self); void* c11_vector__at(c11_vector* self, int index); void c11_vector__reserve(c11_vector* self, int capacity); -c11_array c11_vector__as_array(c11_vector* self); #define c11__getitem(T, self, index) ((T*)(self)->data)[index] #define c11__setitem(T, self, index, value) ((T*)(self)->data)[index] = value; diff --git a/src/common/str.c b/src/common/str.c index e369c1da..bf20a4cd 100644 --- a/src/common/str.c +++ b/src/common/str.c @@ -351,7 +351,7 @@ int pkpy_Str__count(const pkpy_Str *self, const pkpy_Str *sub){ return cnt; } -c11_array/* T=c11_string */ pkpy_Str__split(const pkpy_Str *self, char sep){ +c11_vector/* T=c11_string */ pkpy_Str__split(const pkpy_Str *self, char sep){ c11_vector retval; c11_vector__ctor(&retval, sizeof(c11_string)); const char* data = pkpy_Str__data(self); @@ -370,10 +370,10 @@ c11_array/* T=c11_string */ pkpy_Str__split(const pkpy_Str *self, char sep){ c11_string tmp = {data + i, self->size - i}; c11_vector__push(c11_string, &retval, tmp); } - return c11_vector__as_array(&retval); + return retval; } -c11_array/* T=c11_string */ pkpy_Str__split2(const pkpy_Str *self, const pkpy_Str *sep){ +c11_vector/* T=c11_string */ pkpy_Str__split2(const pkpy_Str *self, const pkpy_Str *sep){ c11_vector retval; c11_vector__ctor(&retval, sizeof(c11_string)); int start = 0; @@ -387,5 +387,5 @@ c11_array/* T=c11_string */ pkpy_Str__split2(const pkpy_Str *self, const pkpy_St } c11_string tmp = {data + start, self->size - start}; if(tmp.size != 0) c11_vector__push(c11_string, &retval, tmp); - return c11_vector__as_array(&retval); + return retval; } diff --git a/src/common/vector.c b/src/common/vector.c index 92137c58..b6212672 100644 --- a/src/common/vector.c +++ b/src/common/vector.c @@ -60,11 +60,3 @@ void c11_vector__reserve(c11_vector* self, int capacity){ self->data = realloc(self->data, self->elem_size * self->capacity); } -c11_array c11_vector__as_array(c11_vector* self){ - c11_array retval = { - .data = self->data, - .count = self->count, - .elem_size = self->elem_size, - }; - return retval; -}