MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / renderedSpanCost

Method renderedSpanCost

src/mcp/tools.ts:6263–6271  ·  view source on GitHub ↗
(start: number, end: number)

Source from the content-addressed store, hash-verified

6261 let lineCostPrefix: number[] | null = null;
6262 /** Rendered chars of lines `start..end` (line numbers included), in O(1). */
6263 const renderedSpanCost = (start: number, end: number): number => {
6264 if (!lineCostPrefix) {
6265 lineCostPrefix = [0];
6266 for (let ln = 1; ln <= fileLines.length; ln++) lineCostPrefix.push(lineCostPrefix[ln - 1]! + lineCost(ln));
6267 }
6268 const s = Math.max(1, start);
6269 const e = Math.min(fileLines.length, end);
6270 return e < s ? 0 : Math.max(0, lineCostPrefix[e]! - lineCostPrefix[s - 1]! - 1);
6271 };
6272 /**
6273 * Longest prefix of `r` that fits `room`. `minLines` is the never-empty
6274 * floor — it may overrun `room`, so it is only ever asked for when nothing

Callers

nothing calls this directly

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected