Skip to content
Snippets Groups Projects
Commit 562cb9ac authored by David Sehnal's avatar David Sehnal
Browse files

comp proof tweak

parent d6e11bb2
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,8 @@ function UniformlyChunked<S>(label: string, initialChunk: number, f: UniformlyCh ...@@ -24,7 +24,8 @@ function UniformlyChunked<S>(label: string, initialChunk: number, f: UniformlyCh
return 0 as any; return 0 as any;
} }
const uniformPart = UniformlyChunked('Reading lines', 1000000, (size, state: { str: string, position: number, lines: string[] }) => { type LineReaderState = { str: string, position: number, lines: string[] }
const uniformPart = UniformlyChunked('Reading lines', 1000000, (size, state: LineReaderState) => {
state.position += size; state.position += size;
state.lines.push(''); state.lines.push('');
return 0 /* number of lines read */; return 0 /* number of lines read */;
...@@ -32,8 +33,7 @@ const uniformPart = UniformlyChunked('Reading lines', 1000000, (size, state: { s ...@@ -32,8 +33,7 @@ const uniformPart = UniformlyChunked('Reading lines', 1000000, (size, state: { s
function readLines(str: string): Computation<string[]> { function readLines(str: string): Computation<string[]> {
return create(async ctx => { return create(async ctx => {
const state = { str, position: 0, lines: [] }; const state = (await uniformPart(ctx, { str, position: 0, lines: [] }));
await uniformPart(ctx, state);
return state.lines; return state.lines;
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment