static _insertBlockInFirstAvailableColumn()

in resources/perf.webkit.org/public/v3/components/analysis-results-viewer.js [313:332]


    static _insertBlockInFirstAvailableColumn(columns, newBlock)
    {
        for (const existingColumn of columns) {
            for (let i = 0; i < existingColumn.length; i++) {
                const currentBlock = existingColumn[i];
                if ((!i || existingColumn[i - 1].endRowIndex() < newBlock.startRowIndex())
                    && newBlock.endRowIndex() < currentBlock.startRowIndex()) {
                    existingColumn.splice(i, 0, newBlock);
                    return;
                }
            }
            const lastBlock = existingColumn[existingColumn.length - 1];
            console.assert(lastBlock);
            if (lastBlock.endRowIndex() < newBlock.startRowIndex()) {
                existingColumn.push(newBlock);
                return;
            }
        }
        columns.push([newBlock]);
    }