Skip to content

Commit

Permalink
Also abbreviate RA names in predicate overview
Browse files Browse the repository at this point in the history
  • Loading branch information
asgerf committed Nov 14, 2024
1 parent 4a2e521 commit 6de1b2f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
import { formatDecimal } from "../../common/number";
import { styled } from "styled-components";
import { Codicon, ViewTitle, WarningBox } from "../common";
import { abbreviateRASteps } from "./RAPrettyPrinter";
import { abbreviateRANames, abbreviateRASteps } from "./RAPrettyPrinter";

const enum AbsentReason {
NotSeen = "NotSeen",
Expand Down Expand Up @@ -364,6 +364,8 @@ export function ComparePerformance(_: Record<string, never>) {
totalDiff += row.diff;
}

const rowNames = abbreviateRANames(rows.map((row) => row.name));

return (
<>
<ViewTitle>Performance comparison</ViewTitle>
Expand Down Expand Up @@ -406,7 +408,7 @@ export function ComparePerformance(_: Record<string, never>) {
</HeaderTR>
</thead>
</Table>
{rows.map((row) => (
{rows.map((row, rowIndex) => (
<Table
key={row.name}
className={expandedPredicates.has(row.name) ? "expanded" : ""}
Expand All @@ -427,7 +429,7 @@ export function ComparePerformance(_: Record<string, never>) {
{renderAbsoluteValue(row.before)}
{renderAbsoluteValue(row.after)}
{renderDelta(row.diff)}
<NameCell>{row.name}</NameCell>
<NameCell>{rowNames[rowIndex]}</NameCell>
</PredicateTR>
{expandedPredicates.has(row.name) && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ interface ExpandableNamePartProps {
function ExpandableNamePart(props: ExpandableNamePartProps) {
const [isExpanded, setExpanded] = useState(false);
return (
<ExpandableTextButton onClick={() => setExpanded(!isExpanded)}>
<ExpandableTextButton
onClick={(event: Event) => {
setExpanded(!isExpanded);
event.stopPropagation();
}}
>
{isExpanded ? props.children : "..."}
</ExpandableTextButton>
);
Expand Down Expand Up @@ -269,3 +274,8 @@ export function abbreviateRASteps(steps: string[]): React.ReactNode[] {
return <Fragment key={index}>{result}</Fragment>;
});
}

export function abbreviateRANames(names: string[]): React.ReactNode[] {
const nameSet = new NameSet(names);
return names.map((name) => nameSet.getAbbreviation(name));
}

0 comments on commit 6de1b2f

Please sign in to comment.