diff options
author | Mateo Radman <48420316+mateoradman@users.noreply.github.com> | 2021-06-05 12:46:13 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-06-05 13:48:26 +0200 |
commit | d6f3b5858991e9609eaefc139dc605b36f9a07b3 (patch) | |
tree | c1bf1b5c92e8c05de2c3af572dbcb0a0769614f4 /django/utils/formats.py | |
parent | 213850b4b9641bdcb714172999725ec9aa9c9e84 (diff) | |
download | django-d6f3b5858991e9609eaefc139dc605b36f9a07b3.tar.gz |
Fixed #32810 -- Optimized django.utils.formats.number_format() a bit.
Pre-calculate use_l10n for get_format() calls.
Diffstat (limited to 'django/utils/formats.py')
-rw-r--r-- | django/utils/formats.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py index 3bad64150a..d6eccf6b68 100644 --- a/django/utils/formats.py +++ b/django/utils/formats.py @@ -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), |