mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Replace sort_attrs (insertion sort) with a single insertion (#11181)
Fixes #11164
This commit is contained in:
parent
2413ef6d93
commit
884f057646
@ -93,18 +93,6 @@ static const char **attr_at(RConsCanvas *c, int loc) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void sort_attrs(RConsCanvas *c) {
|
||||
int i, j;
|
||||
RConsCanvasAttr value;
|
||||
for (i = 1; i < c->attrslen; i++) {
|
||||
value = c->attrs[i];
|
||||
for (j = i - 1; j >= 0 && c->attrs[j].loc > value.loc; j--) {
|
||||
c->attrs[j + 1] = c->attrs[j];
|
||||
}
|
||||
c->attrs[j + 1] = value;
|
||||
}
|
||||
}
|
||||
|
||||
static void stamp_attr(RConsCanvas *c, int loc, int length) {
|
||||
if (!c->color) {
|
||||
return;
|
||||
@ -126,10 +114,12 @@ static void stamp_attr(RConsCanvas *c, int loc, int length) {
|
||||
}
|
||||
*s = c->attr;
|
||||
} else {
|
||||
c->attrs[c->attrslen].loc = loc;
|
||||
c->attrs[c->attrslen].a = c->attr;
|
||||
for (i = c->attrslen; i > 0 && loc < c->attrs[i].loc; i--) {
|
||||
c->attrs[i] = c->attrs[i - 1];
|
||||
}
|
||||
c->attrs[i].loc = loc;
|
||||
c->attrs[i].a = c->attr;
|
||||
c->attrslen++;
|
||||
sort_attrs (c);
|
||||
}
|
||||
|
||||
for (i = 1; i < length; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user