Skip to content
Snippets Groups Projects
Commit c6485149 authored by dsehnal's avatar dsehnal
Browse files

applyMarkerAction take 2

parent 4a2e93e2
No related branches found
No related tags found
No related merge requests found
......@@ -68,11 +68,19 @@ export function applyMarkerAction(array: Uint8Array, set: OrderedSet, action: Ma
if (Interval.is(set)) {
const start = Interval.start(set);
const end = Interval.end(set);
const view = new Uint32Array(array.buffer, 0, array.buffer.byteLength >> 2);
const viewStart = (start + 3) >> 2;
const viewEnd = viewStart + ((end - 4 * viewStart) >> 2);
if (viewEnd <= viewStart) {
// avoid edge cases with overlapping front/end intervals
for (let i = start; i < end; ++i) {
applyMarkerActionAtPosition(array, i, action);
}
return true;
}
const view = new Uint32Array(array.buffer, 0, array.buffer.byteLength >> 2);
const frontStart = start;
const frontEnd = Math.min(4 * viewStart, end);
const backStart = Math.max(start, 4 * viewEnd);
......@@ -105,13 +113,8 @@ export function applyMarkerAction(array: Uint8Array, set: OrderedSet, action: Ma
applyMarkerActionAtPosition(array, i, action);
}
// to prevent applying "toggle" twice check for edge case where
// viewEnd <= viewStart, which resolves to the "front" and "back"
// intervals being the same range
if (frontStart !== backStart) {
for (let i = backStart; i < backEnd; ++i) {
applyMarkerActionAtPosition(array, i, action);
}
for (let i = backStart; i < backEnd; ++i) {
applyMarkerActionAtPosition(array, i, action);
}
} else {
switch (action) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment