Ver a proveniência

Fix Textbuffer_reverse()

tags/v0.4.1
Ben Kurtovic há 9 anos
ascendente
cometimento
8963c1f683
1 ficheiros alterados com 6 adições e 6 eliminações
  1. +6
    -6
      mwparserfromhell/parser/ctokenizer/textbuffer.c

+ 6
- 6
mwparserfromhell/parser/ctokenizer/textbuffer.c Ver ficheiro

@@ -214,19 +214,19 @@ int Textbuffer_concat(Textbuffer* self, Textbuffer* other)
*/ */
void Textbuffer_reverse(Textbuffer* self) void Textbuffer_reverse(Textbuffer* self)
{ {
Py_ssize_t i, mid = self->length / 2;
Py_ssize_t i, end = self->length - 1;
Unicode tmp; Unicode tmp;


for (i = 0; i < mid; i++) {
for (i = 0; i < self->length / 2; i++) {
#ifdef PEP_393 #ifdef PEP_393
tmp = PyUnicode_READ(self->kind, self->data, i); tmp = PyUnicode_READ(self->kind, self->data, i);
PyUnicode_WRITE(self->kind, self->data, i, PyUnicode_WRITE(self->kind, self->data, i,
PyUnicode_READ(self->kind, self->data, mid + i));
PyUnicode_WRITE(self->kind, self->data, mid + i, tmp);
PyUnicode_READ(self->kind, self->data, end - i));
PyUnicode_WRITE(self->kind, self->data, end - i, tmp);
#else #else
tmp = self->data[i]; tmp = self->data[i];
self->data[i] = self->data[mid + i];
self->data[mid + i] = tmp;
self->data[i] = self->data[end - i];
self->data[end - i] = tmp;
#endif #endif
} }
} }

Carregando…
Cancelar
Guardar