mirror of
https://github.com/typst/typst
synced 2025-06-15 16:46:24 +08:00
convert const into non-const argument
it is still inlined.
This commit is contained in:
parent
bb6cd47c68
commit
88c9dea3fa
@ -2182,13 +2182,14 @@ fn resolve_cell_position(
|
|||||||
// Note that the counter ignores any cells with fixed positions,
|
// Note that the counter ignores any cells with fixed positions,
|
||||||
// but automatically-positioned cells will avoid conflicts by
|
// but automatically-positioned cells will avoid conflicts by
|
||||||
// simply skipping existing cells, headers and footers.
|
// simply skipping existing cells, headers and footers.
|
||||||
let resolved_index = find_next_available_position::<false>(
|
let resolved_index = find_next_available_position(
|
||||||
headers,
|
headers,
|
||||||
footer,
|
footer,
|
||||||
resolved_cells,
|
resolved_cells,
|
||||||
columns,
|
columns,
|
||||||
*auto_index,
|
*auto_index,
|
||||||
next_header,
|
next_header,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Ensure the next cell with automatic position will be
|
// Ensure the next cell with automatic position will be
|
||||||
@ -2241,7 +2242,7 @@ fn resolve_cell_position(
|
|||||||
// requested column ('Some(None)') or an out of bounds position
|
// requested column ('Some(None)') or an out of bounds position
|
||||||
// ('None'), in which case we'd create a new row to place this
|
// ('None'), in which case we'd create a new row to place this
|
||||||
// cell in.
|
// cell in.
|
||||||
find_next_available_position::<true>(
|
find_next_available_position(
|
||||||
headers,
|
headers,
|
||||||
footer,
|
footer,
|
||||||
resolved_cells,
|
resolved_cells,
|
||||||
@ -2262,6 +2263,7 @@ fn resolve_cell_position(
|
|||||||
// Still, it is something to consider for the future if
|
// Still, it is something to consider for the future if
|
||||||
// this turns out to be a bottleneck in important cases.
|
// this turns out to be a bottleneck in important cases.
|
||||||
&mut 0,
|
&mut 0,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2303,14 +2305,18 @@ fn resolve_cell_position(
|
|||||||
/// Finds the first available position after the initial index in the resolved
|
/// Finds the first available position after the initial index in the resolved
|
||||||
/// grid of cells. Skips any non-absent positions (positions which already
|
/// grid of cells. Skips any non-absent positions (positions which already
|
||||||
/// have cells specified by the user) as well as any headers and footers.
|
/// have cells specified by the user) as well as any headers and footers.
|
||||||
|
///
|
||||||
|
/// When `skip_rows` is true, one row is skipped on each iteration, preserving
|
||||||
|
/// the column. That is used to find a position for a fixed column cell.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn find_next_available_position<const SKIP_ROWS: bool>(
|
fn find_next_available_position(
|
||||||
headers: &[Repeatable<Header>],
|
headers: &[Repeatable<Header>],
|
||||||
footer: Option<&(usize, Span, Footer)>,
|
footer: Option<&(usize, Span, Footer)>,
|
||||||
resolved_cells: &[Option<Entry<'_>>],
|
resolved_cells: &[Option<Entry<'_>>],
|
||||||
columns: usize,
|
columns: usize,
|
||||||
initial_index: usize,
|
initial_index: usize,
|
||||||
next_header: &mut usize,
|
next_header: &mut usize,
|
||||||
|
skip_rows: bool,
|
||||||
) -> HintedStrResult<usize> {
|
) -> HintedStrResult<usize> {
|
||||||
let mut resolved_index = initial_index;
|
let mut resolved_index = initial_index;
|
||||||
|
|
||||||
@ -2320,7 +2326,7 @@ fn find_next_available_position<const SKIP_ROWS: bool>(
|
|||||||
// determine where this cell will be placed. An out of
|
// determine where this cell will be placed. An out of
|
||||||
// bounds position (thus `None`) is also a valid new
|
// bounds position (thus `None`) is also a valid new
|
||||||
// position (only requires expanding the vector).
|
// position (only requires expanding the vector).
|
||||||
if SKIP_ROWS {
|
if skip_rows {
|
||||||
// Skip one row at a time (cell chose its column, so we don't
|
// Skip one row at a time (cell chose its column, so we don't
|
||||||
// change it).
|
// change it).
|
||||||
resolved_index =
|
resolved_index =
|
||||||
@ -2344,7 +2350,7 @@ fn find_next_available_position<const SKIP_ROWS: bool>(
|
|||||||
if resolved_index < header.end * columns {
|
if resolved_index < header.end * columns {
|
||||||
resolved_index = header.end * columns;
|
resolved_index = header.end * columns;
|
||||||
|
|
||||||
if SKIP_ROWS {
|
if skip_rows {
|
||||||
// Ensure the cell's chosen column is kept after the
|
// Ensure the cell's chosen column is kept after the
|
||||||
// header.
|
// header.
|
||||||
resolved_index += initial_index % columns;
|
resolved_index += initial_index % columns;
|
||||||
@ -2359,7 +2365,7 @@ fn find_next_available_position<const SKIP_ROWS: bool>(
|
|||||||
// Skip footer, for the same reason.
|
// Skip footer, for the same reason.
|
||||||
resolved_index = *footer_end * columns;
|
resolved_index = *footer_end * columns;
|
||||||
|
|
||||||
if SKIP_ROWS {
|
if skip_rows {
|
||||||
resolved_index += initial_index % columns;
|
resolved_index += initial_index % columns;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user