mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[poincare/utf8_decoder] nextCodePointPointer is now stringPosition
This commit is contained in:
@@ -18,10 +18,8 @@
|
||||
class UTF8Decoder {
|
||||
public:
|
||||
UTF8Decoder(const char * string) : m_string(string) {}
|
||||
/* TODO: Rename methods? nextCodePoint increases m_string but
|
||||
* nextCodePointPointer does not */
|
||||
CodePoint nextCodePoint();
|
||||
const char * nextCodePointPointer();
|
||||
const char * stringPosition() const { return m_string; }
|
||||
static size_t CharSizeOfCodePoint(CodePoint c);
|
||||
static size_t CodePointToChars(CodePoint c, char * buffer, int bufferSize);
|
||||
private:
|
||||
|
||||
@@ -25,10 +25,6 @@ CodePoint UTF8Decoder::nextCodePoint() {
|
||||
return CodePoint(result);
|
||||
}
|
||||
|
||||
const char * UTF8Decoder::nextCodePointPointer() {
|
||||
return m_string + leading_ones(*m_string);
|
||||
}
|
||||
|
||||
size_t UTF8Decoder::CharSizeOfCodePoint(CodePoint c) {
|
||||
constexpr int bufferSize = CodePoint::MaxCodePointCharLength;
|
||||
char buffer[bufferSize];
|
||||
|
||||
@@ -10,12 +10,12 @@ static inline int min(int x, int y) { return x < y ? x : y; }
|
||||
const char * CodePointSearch(const char * s, CodePoint c) {
|
||||
UTF8Decoder decoder(s);
|
||||
const char * currentPointer = s;
|
||||
const char * nextPointer = decoder.nextCodePointPointer();
|
||||
CodePoint codePoint = decoder.nextCodePoint();
|
||||
const char * nextPointer = decoder.stringPosition();
|
||||
while (codePoint != KDCodePointNull && codePoint != c) {
|
||||
currentPointer = nextPointer;
|
||||
nextPointer = decoder.nextCodePointPointer();
|
||||
codePoint = decoder.nextCodePoint();
|
||||
nextPointer = decoder.stringPosition();
|
||||
}
|
||||
if (codePoint == c) {
|
||||
return currentPointer;
|
||||
@@ -26,9 +26,9 @@ const char * CodePointSearch(const char * s, CodePoint c) {
|
||||
void CopyAndRemoveCodePoint(char * dst, size_t dstSize, const char * src, CodePoint c, size_t * indexToUpdate) {
|
||||
UTF8Decoder decoder(src);
|
||||
const char * currentPointer = src;
|
||||
const char * nextPointer = decoder.nextCodePointPointer();
|
||||
const char * maxPointer = src + strlen(src) + 1;
|
||||
CodePoint codePoint = decoder.nextCodePoint();
|
||||
const char * nextPointer = decoder.stringPosition();
|
||||
size_t bufferIndex = 0;
|
||||
size_t codePointCharSize = UTF8Decoder::CharSizeOfCodePoint(c);
|
||||
|
||||
@@ -43,8 +43,8 @@ void CopyAndRemoveCodePoint(char * dst, size_t dstSize, const char * src, CodePo
|
||||
*indexToUpdate-= codePointCharSize;
|
||||
}
|
||||
currentPointer = nextPointer;
|
||||
nextPointer = decoder.nextCodePointPointer();
|
||||
codePoint = decoder.nextCodePoint();
|
||||
nextPointer = decoder.stringPosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user