pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://github.com/payloadcms/payload/commit/76f3693

967feea1e66.css" /> perf: skip validation for default timezones (#16129) · payloadcms/payload@76f3693 · GitHub
Skip to content

Commit 76f3693

Browse files
perf: skip validation for default timezones (#16129)
Payload's 48 hardcoded default timezones were being validated with `new Intl.DateTimeFormat()` on every cold start. This is unnecessary since they're known to be valid. This change pre-computes a `Set` of default timezone values at module load and skips validation for any timezone in that set. Custom/user-provided timezones are still validated. ### Before/After | Operation | Before | After | |-----------|--------|-------| | `sanitizeAdminConfig` | 9.18ms | 0.17ms | | `validateTimezones` | 9.06ms | 0.03ms |
1 parent a65e715 commit 76f3693

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/payload/src/utilities/validateTimezones.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { Timezone } from '../config/types.js'
22

33
import { InvalidConfiguration } from '../errors/index.js'
4+
import { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'
5+
6+
// Pre-computed Set of default timezone values - skip validation for these
7+
const defaultTimezoneValues = new Set(defaultTimezones.map((tz) => tz.value))
48

59
type ValidateTimezonesArgs = {
610
/**
@@ -91,6 +95,10 @@ export const validateTimezones = ({ source, timezones }: ValidateTimezonesArgs):
9195
}
9296

9397
for (const timezone of timezones) {
98+
// Skip validation for known-valid default timezones
99+
if (defaultTimezoneValues.has(timezone.value)) {
100+
continue
101+
}
94102
if (!isTimezoneSupported(timezone.value)) {
95103
const sourceText = source ? ` in ${source}` : ''
96104
throw new InvalidConfiguration(

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy