bytes: make search linear and splits consistent
This commit is contained in:
@@ -110,6 +110,27 @@ import bytes;
|
||||
case let i: i32 => { assert(!(i != 3)); };
|
||||
case void => abort();
|
||||
};
|
||||
|
||||
// Periodic long needles exercise the two-way path's critical-period
|
||||
// memory. The first candidate shares a long prefix and must be skipped
|
||||
// without missing the later match; the second never matches.
|
||||
let hp: [18]u8;
|
||||
let np: [7]u8;
|
||||
let i: i32 = 0;
|
||||
for (i < 18) { hp[i] = 'a'; i += 1; };
|
||||
hp[8] = 'b'; hp[17] = 'b';
|
||||
i = 0;
|
||||
for (i < 6) { np[i] = 'a'; i += 1; };
|
||||
np[6] = 'b';
|
||||
match (bytes.index(hp[0:18], np[0:7])) {
|
||||
case let off: i32 => { assert(!(off != 2)); };
|
||||
case void => abort();
|
||||
};
|
||||
np[6] = 'c';
|
||||
match (bytes.index(hp[0:18], np[0:7])) {
|
||||
case let off: i32 => abort();
|
||||
case void => void;
|
||||
};
|
||||
};
|
||||
|
||||
// ref/hare/bytes/index.ha:118.
|
||||
|
||||
Reference in New Issue
Block a user