mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-28 13:30:29 +00:00
Brush up some more code
This commit is contained in:
parent
ee6566a152
commit
a2d269dc38
32 changed files with 251 additions and 335 deletions
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/midpoint.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/mem/sortedints.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -28,7 +27,7 @@ bool ContainsInt(const struct SortedInts *t, int k) {
|
|||
l = 0;
|
||||
r = t->n - 1;
|
||||
while (l <= r) {
|
||||
m = _midpoint(l, r);
|
||||
m = (l & r) + ((l ^ r) >> 1); // floor((a+b)/2)
|
||||
if (t->p[m] < k) {
|
||||
l = m + 1;
|
||||
} else if (t->p[m] > k) {
|
||||
|
@ -45,7 +44,7 @@ int LeftmostInt(const struct SortedInts *t, int k) {
|
|||
l = 0;
|
||||
r = t->n;
|
||||
while (l < r) {
|
||||
m = _midpoint(l, r);
|
||||
m = (l & r) + ((l ^ r) >> 1); // floor((a+b)/2)
|
||||
if (t->p[m] < k) {
|
||||
l = m + 1;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue