ref: 3c9475870a081bd6e13872a17f417c85de978416
parent: 0a2b6b19d93ae65bae4e78ee4d97a8753a08811c
author: qwx <[email protected]>
date: Thu Feb 9 14:10:41 EST 2023
get rid of comparisons to -1
--- a/chunk.c
+++ b/chunk.c
@@ -231,7 +231,7 @@
dot.to = n;
if(dot.pos < dot.from || dot.pos > dot.to)
dot.pos = dot.from;
- dot.at = -1ULL;
+ dot.at = dot.from;
dprint(nil, "final %Δ\n", &dot);
totalsz = n;
}
@@ -271,7 +271,7 @@
dot->to = c2p(norris->left) + norris->left->len;
else
dot->to = c2p(right);
- dot->at = -1ULL;
+ dot->at = dot->from;
}
void
--- a/cmd.c
+++ b/cmd.c
@@ -40,7 +40,7 @@
dot.to = to;
if(dot.pos < from || dot.pos >= to)
dot.pos = from;
- dot.at = -1;
+ dot.at = dot.from;
}
int
@@ -134,11 +134,11 @@
fprint(2, "insert: nothing to paste\n");
return -1;
}
- if(dot.at == -1){
+ if(dot.at == dot.from){
fprint(2, "insert: nowhere to paste\n");
return -1;
}
- assert(dot.at <= dot.to);
+ assert(dot.at >= dot.from && dot.at <= dot.to);
dprint(nil, "cmd/insert %Δ\n", &dot);
dprint(c, "buffered\n");
pushop(OPins, dot.at, dot.at+chunklen(c)-1, nil);
@@ -148,7 +148,7 @@
}
setdot(&dot, nil);
dot.pos = c2p(left->right);
- dot.at = -1;
+ dot.at = dot.from;
dprint(nil, "end\n");
return 1;
}
--- a/draw.c
+++ b/draw.c
@@ -184,7 +184,7 @@
seprint(s, s+sizeof s, " ↺ %τ - %τ", dot.from, dot.to);
p = string(screen, p, col[Cloop], ZP, font, s);
}
- if(dot.at != -1){
+ if(dot.at != dot.from && dot.at != dot.to){
seprint(s, s+sizeof s, " ‡ %τ", dot.at);
p = string(screen, p, col[Cins], ZP, font, s);
}
@@ -198,7 +198,8 @@
drawchunks();
drawpos(dot.from, col[Cloop]);
drawpos(dot.to, col[Cloop]);
- drawpos(dot.at, col[Cins]);
+ if(dot.at != dot.from && dot.at != dot.to)
+ drawpos(dot.at, col[Cins]);
}
void