mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-27 03:09:43 +02:00
GitGraph: refactored overlapping fn for efficiency/performance
On previous rewrite, I had created new functions within the overlapping functions but these were being recreated on each iteration of Object.some(). I moved them outside this for clarity and so they're not recreated each iteration.
This commit is contained in:
@@ -351,17 +351,18 @@ const drawCommits = (svg, commits, modifyGraph) => {
|
||||
* commitA's x-position
|
||||
* and commitB's x-position
|
||||
*/
|
||||
const hasOverlappingCommits = (commitA, commitB, allCommits) =>
|
||||
Object.values(allCommits).some((commitX) => {
|
||||
const isOnSourceBranch = (x) => x.branch === commitA.branch;
|
||||
const isOnTargetBranch = (x) => x.branch === commitB.branch;
|
||||
const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq;
|
||||
const isTargetMain = (x) => x.branch === getConfig().gitGraph.mainBranchName;
|
||||
const hasOverlappingCommits = (commitA, commitB, allCommits) => {
|
||||
const isOnSourceBranch = (x) => x.branch === commitA.branch;
|
||||
const isOnTargetBranch = (x) => x.branch === commitB.branch;
|
||||
const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq;
|
||||
const isTargetMain = (x) => x.branch === getConfig().gitGraph.mainBranchName;
|
||||
return Object.values(allCommits).some((commitX) => {
|
||||
return (
|
||||
(isOnSourceBranch(commitX) || (isOnTargetBranch(commitX) && !isTargetMain(commitX))) &&
|
||||
isBetweenCommits(commitX)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* This function find a lane in the y-axis that is not overlapping with any other lanes. This is
|
||||
|
Reference in New Issue
Block a user