0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

Fixed #32810 -- Optimized django.utils.formats.number_format() a bit.

Pre-calculate use_l10n for get_format() calls.
This commit is contained in:
Mateo Radman 2021-06-05 12:46:13 +02:00 committed by Mariusz Felisiak
parent 213850b4b9
commit d6f3b58589

View File

@ -171,10 +171,8 @@ def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False):
If use_l10n is provided and is not None, it forces the value to
be localized (or not), overriding the value of settings.USE_L10N.
"""
if use_l10n or (use_l10n is None and settings.USE_L10N):
lang = get_language()
else:
lang = None
use_l10n = use_l10n or (use_l10n is None and settings.USE_L10N)
lang = get_language() if use_l10n else None
return numberformat.format(
value,
get_format('DECIMAL_SEPARATOR', lang, use_l10n=use_l10n),