diff --git a/packages/react-native/Libraries/StyleSheet/__tests__/processBoxShadow-itest.js b/packages/react-native/Libraries/StyleSheet/__tests__/processBoxShadow-itest.js index f6c408728bdf..9ba8ad73373b 100644 --- a/packages/react-native/Libraries/StyleSheet/__tests__/processBoxShadow-itest.js +++ b/packages/react-native/Libraries/StyleSheet/__tests__/processBoxShadow-itest.js @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. * * @flow strict-local - * @fantom_flags enableOptimizedBoxShadowParsing:* * @format */ diff --git a/packages/react-native/Libraries/StyleSheet/processBoxShadow.js b/packages/react-native/Libraries/StyleSheet/processBoxShadow.js index e29026fab7c6..75ea41c58a5d 100644 --- a/packages/react-native/Libraries/StyleSheet/processBoxShadow.js +++ b/packages/react-native/Libraries/StyleSheet/processBoxShadow.js @@ -11,10 +11,8 @@ import type {ProcessedColorValue} from './processColor'; import type {BoxShadowValue} from './StyleSheetTypes'; -import {enableOptimizedBoxShadowParsing} from '../../src/private/featureflags/ReactNativeFeatureFlags'; import processColor from './processColor'; -// Pre-compiled regex patterns for performance - avoids regex compilation on each call const COMMA_SPLIT_REGEX = /,(?![^()]*\))/; const WHITESPACE_SPLIT_REGEX = /\s+(?![^(]*\))/; const LENGTH_PARSE_REGEX = /^([+-]?\d*\.?\d+)(px)?$/; @@ -39,12 +37,7 @@ export default function processBoxShadow( const boxShadowList = typeof rawBoxShadows === 'string' - ? parseBoxShadowString( - rawBoxShadows.replace( - enableOptimizedBoxShadowParsing() ? NEWLINE_REGEX : /\n/g, - ' ', - ), - ) + ? parseBoxShadowString(rawBoxShadows.replace(NEWLINE_REGEX, ' ')) : rawBoxShadows; for (const rawBoxShadow of boxShadowList) { @@ -121,9 +114,7 @@ function parseBoxShadowString(rawBoxShadows: string): Array { let result: Array = []; for (const rawBoxShadow of rawBoxShadows - .split( - enableOptimizedBoxShadowParsing() ? COMMA_SPLIT_REGEX : /,(?![^()]*\))/, - ) // split by comma that is not in parenthesis + .split(COMMA_SPLIT_REGEX) .map(bS => bS.trim()) .filter(bS => bS !== '')) { const boxShadow: BoxShadowValue = { @@ -137,11 +128,7 @@ function parseBoxShadowString(rawBoxShadows: string): Array { let lengthCount = 0; // split rawBoxShadow string by all whitespaces that are not in parenthesis - const args = rawBoxShadow.split( - enableOptimizedBoxShadowParsing() - ? WHITESPACE_SPLIT_REGEX - : /\s+(?![^(]*\))/, - ); + const args = rawBoxShadow.split(WHITESPACE_SPLIT_REGEX); for (const arg of args) { const processedColor = processColor(arg); if (processedColor != null) { @@ -210,43 +197,18 @@ function parseBoxShadowString(rawBoxShadows: string): Array { } function parseLength(length: string): ?number { - if (enableOptimizedBoxShadowParsing()) { - // Use pre-compiled regex for performance - const match = LENGTH_PARSE_REGEX.exec(length); + const match = LENGTH_PARSE_REGEX.exec(length); - if (!match) { - return null; - } - - const value = parseFloat(match[1]); - if (Number.isNaN(value)) { - return null; - } - - // match[2] is 'px' or undefined - // If no unit and value is not 0, return null - if (match[2] == null && value !== 0) { - return null; - } - - return value; - } - - // matches on args with units like "1.5 5% -80deg" - const argsWithUnitsRegex = /([+-]?\d*(\.\d+)?)([\w\W]+)?/g; - const match = argsWithUnitsRegex.exec(length); - - if (!match || Number.isNaN(match[1])) { + if (!match) { return null; } - if (match[3] != null && match[3] !== 'px') { - return null; - } + const value = parseFloat(match[1]); - if (match[3] == null && match[1] !== '0') { + // If no unit (px) and value is not 0, reject it + if (match[2] == null && value !== 0) { return null; } - return Number(match[1]); + return value; } diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 1d6ffadb4af6..78dbf32ad3f4 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -1054,17 +1054,6 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, - enableOptimizedBoxShadowParsing: { - defaultValue: false, - metadata: { - dateAdded: '2026-02-26', - description: - 'Hoists regex patterns to module scope and optimizes parseLength in processBoxShadow for improved performance.', - expectedReleaseValue: true, - purpose: 'experimentation', - }, - ossReleaseStage: 'none', - }, externalElementInspectionEnabled: { defaultValue: true, metadata: { diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 3deb4d238223..67e7bcbbe95e 100644 --- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<5966ef11ee71a38059decda1c529fd6f>> + * @generated SignedSource<<0fffffdeaf8ab7210131ac789f8b208b>> * @flow strict * @noformat */ @@ -33,7 +33,6 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{ animatedShouldUseSingleOp: Getter, deferFlatListFocusChangeRenderUpdate: Getter, disableMaintainVisibleContentPosition: Getter, - enableOptimizedBoxShadowParsing: Getter, externalElementInspectionEnabled: Getter, fixImageSrcDimensionPropagation: Getter, fixVirtualizeListCollapseWindowSize: Getter, @@ -165,11 +164,6 @@ export const deferFlatListFocusChangeRenderUpdate: Getter = createJavaS */ export const disableMaintainVisibleContentPosition: Getter = createJavaScriptFlagGetter('disableMaintainVisibleContentPosition', false); -/** - * Hoists regex patterns to module scope and optimizes parseLength in processBoxShadow for improved performance. - */ -export const enableOptimizedBoxShadowParsing: Getter = createJavaScriptFlagGetter('enableOptimizedBoxShadowParsing', false); - /** * Enable the external inspection API for DevTools to communicate with the Inspector overlay. */