From 557d32fe04fa747b1052f0a0f04d26541266c3a7 Mon Sep 17 00:00:00 2001 From: Marcus Aurelius Date: Mon, 10 Mar 2025 15:41:53 +0100 Subject: [PATCH] Add fast exit if no params provided After analyse and debugg code we encounter that even we provide no params the logic runs through the interpolation stack. If their no Params provide an exit is here already possible to return the translated value directly --- projects/ngx-translate/src/lib/translate.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/ngx-translate/src/lib/translate.service.ts b/projects/ngx-translate/src/lib/translate.service.ts index 90d790b..fdd8aff 100644 --- a/projects/ngx-translate/src/lib/translate.service.ts +++ b/projects/ngx-translate/src/lib/translate.service.ts @@ -330,10 +330,14 @@ export class TranslateService { private getParsedResultForKey(key: string, interpolateParams?: InterpolationParameters): Translation|Observable { const textToInterpolate = this.getTextToInterpolate(key); - + if (isDefinedAndNotNull(textToInterpolate)) { + //Fast exit to avoid overhead if no params provided + if(isDefinedAndNotNull(interpolateParams)) return this.runInterpolation(textToInterpolate, interpolateParams); + else + return textToInterpolate; } const res = this.missingTranslationHandler.handle({