More efficient memory layout for Line

This commit is contained in:
Kovid Goyal
2016-10-17 08:24:16 +05:30
parent 9de6387e58
commit 2b3855eea9
3 changed files with 83 additions and 36 deletions

View File

@@ -13,8 +13,7 @@ class BaseTest(TestCase):
def set_text_in_line(line, text, offset=0):
pos = offset
for ch in text:
line.char[pos] = ord(ch)
line.width[pos] = 1
line.set_char(pos, ch)
pos += 1
if pos >= len(line):
break

View File

@@ -61,3 +61,14 @@ class TestDataTypes(BaseTest):
l = lo.copy()
l.left_shift(7, 3)
self.ae(str(l), t)
l = Line(1)
l.set_decoration(0, 2)
q = Cursor()
for x in 'bold italic reverse strikethrough'.split():
getattr(l, 'set_' + x)(0, True)
setattr(q, x, True)
q.decoration = 2
l.set_decoration(0, q.decoration)
c = l.cursor_from(0)
self.ae(c, q)