From cbb396c0064d77ec50a524241d22746c8b69bbdb Mon Sep 17 00:00:00 2001 From: Ibrahn Sahir Date: Mon, 7 Jan 2019 17:02:55 +0000 Subject: Repair String lstrip and rstrip. Background: lstrip and rstrip were broken by changes to String in: 0e29f7974b59e4440cf02e1388fb9d8ab2b5c5fd which removed it's access to Vector::find(CharType). Moved Vector's find up into CowData so it can be shared by Vector and String. Added String::find_char using CowData::find. Implemented rstrip and lstrip using find_char. Added a few tests for String rstrip and lstrip. --- core/vector.h | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'core/vector.h') diff --git a/core/vector.h b/core/vector.h index 74dc9191d8..90b3d90826 100644 --- a/core/vector.h +++ b/core/vector.h @@ -84,6 +84,7 @@ public: Error resize(int p_size) { return _cowdata.resize(p_size); } _FORCE_INLINE_ const T &operator[](int p_index) const { return _cowdata.get(p_index); } Error insert(int p_pos, const T &p_val) { return _cowdata.insert(p_pos, p_val); } + int find(const T &p_val, int p_from = 0) const { return _cowdata.find(p_val, p_from); } void append_array(const Vector &p_other); @@ -115,22 +116,6 @@ public: insert(i, p_val); } - int find(const T &p_val, int p_from = 0) const { - int ret = -1; - if (p_from < 0 || size() == 0) - return ret; - - for (int i = p_from; i < size(); i++) { - - if (ptr()[i] == p_val) { - ret = i; - break; - }; - }; - - return ret; - } - _FORCE_INLINE_ Vector() {} _FORCE_INLINE_ Vector(const Vector &p_from) { _cowdata._ref(p_from._cowdata); } inline Vector &operator=(const Vector &p_from) { -- cgit v1.2.3