From ac443110fc01bd5f21807f77900c6bb01741bee5 Mon Sep 17 00:00:00 2001 From: Divine Niiquaye Ibok Date: Thu, 5 Feb 2026 19:16:07 +0000 Subject: [PATCH 1/2] feat: optimize cache key generation for better performance --- packages/uniwind/src/core/native/store.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/uniwind/src/core/native/store.ts b/packages/uniwind/src/core/native/store.ts index 62c6e337..7c549675 100644 --- a/packages/uniwind/src/core/native/store.ts +++ b/packages/uniwind/src/core/native/store.ts @@ -28,12 +28,11 @@ class UniwindStoreBuilder { return emptyState } - const cacheKey = `${className}${state?.isDisabled ?? false}${state?.isFocused ?? false}${state?.isPressed ?? false}` - - if (this.cache.has(cacheKey)) { - return this.cache.get(cacheKey)! - } + const stateFlags = (state?.isDisabled ? 4 : 0) | (state?.isFocused ? 2 : 0) | (state?.isPressed ? 1 : 0) + const cacheKey = `${className}:${stateFlags}` + const cached = this.cache.get(cacheKey) + if (cached) return cached const result = this.resolveStyles(className, componentProps, state) // Don't cache styles that depend on data attributes From fe51d5a1baba64b7c0892b3c2276fab6e5c5e97c Mon Sep 17 00:00:00 2001 From: Divine Niiquaye Ibok Date: Tue, 10 Feb 2026 01:56:29 +0000 Subject: [PATCH 2/2] fix: improve readability & refine style caching --- packages/uniwind/src/core/native/store.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/uniwind/src/core/native/store.ts b/packages/uniwind/src/core/native/store.ts index 7c549675..73e728d6 100644 --- a/packages/uniwind/src/core/native/store.ts +++ b/packages/uniwind/src/core/native/store.ts @@ -11,9 +11,10 @@ type StylesResult = { styles: RNStyle dependencies: Array dependencySum: number + hasDataAttributes: boolean } -const emptyState: StylesResult = { styles: {}, dependencies: [], dependencySum: 0 } +const emptyState: StylesResult = { styles: {}, dependencies: [], dependencySum: 0, hasDataAttributes: false } class UniwindStoreBuilder { runtime = UniwindRuntime @@ -28,11 +29,16 @@ class UniwindStoreBuilder { return emptyState } - const stateFlags = (state?.isDisabled ? 4 : 0) | (state?.isFocused ? 2 : 0) | (state?.isPressed ? 1 : 0) + const stateFlags = (state ? 8 : 0) + | (state?.isDisabled ? 4 : 0) + | (state?.isFocused ? 2 : 0) + | (state?.isPressed ? 1 : 0) const cacheKey = `${className}:${stateFlags}` - const cached = this.cache.get(cacheKey) - if (cached) return cached + if (this.cache.has(cacheKey)) { + return this.cache.get(cacheKey)! + } + const result = this.resolveStyles(className, componentProps, state) // Don't cache styles that depend on data attributes