From 7855edae6babc14f9de9dd6de070d71e6800ba53 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Thu, 15 Dec 2022 20:20:04 +0000 Subject: [PATCH] perf(er): pre-calculcate er UUID namespace Pre-calculate the entity-relationship diagram namespace UUID. This UUID is always constant, so we can pre-calculate it to save a bit of processing power on the client. Co-authored-by: "Ashley Engelund (weedySeaDragon @ github)" Co-authored-by: Sidharth Vinod --- .../mermaid/src/diagrams/er/erRenderer.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/mermaid/src/diagrams/er/erRenderer.js b/packages/mermaid/src/diagrams/er/erRenderer.js index 7a7920160..08b448219 100644 --- a/packages/mermaid/src/diagrams/er/erRenderer.js +++ b/packages/mermaid/src/diagrams/er/erRenderer.js @@ -643,11 +643,20 @@ export const draw = function (text, id, _version, diagObj) { svg.attr('viewBox', `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); }; // draw -/** UUID namespace for ER diagram IDs */ -const MERMAID_ERDIAGRAM_UUID = uuid5( - 'https://mermaid-js.github.io/mermaid/syntax/entityRelationshipDiagram.html', - uuid5.URL -); +/** + * UUID namespace for ER diagram IDs + * + * This can be generated via running: + * + * ```js + * const { v5: uuid5 } = await import('uuid'); + * uuid5( + * 'https://mermaid-js.github.io/mermaid/syntax/entityRelationshipDiagram.html', + * uuid5.URL + * ); + * ``` + */ +const MERMAID_ERDIAGRAM_UUID = '28e9f9db-3c8d-5aa5-9faf-44286ae5937c'; /** * Return a unique id based on the given string. Start with the prefix, then a hyphen, then the