Skip to content

Commit

Permalink
Use mergeFast in a hotspot
Browse files Browse the repository at this point in the history
Summary:
In profiling our app, we found that the usage
of `merge` in `Text.js` was showing up as a
hotspot. We've replaced this usage of `merge`
with `mergeFast`.

**Test plan (required)**

This change is used in my team's app.

Adam Comella
Microsoft Corp.
Closes #9654

Differential Revision: D3801791

fbshipit-source-id: 004652ed6537b557d00541ab2e5fbe64b56fa73b
  • Loading branch information
Adam Comella authored and Facebook Github Bot 7 committed Sep 1, 2016
1 parent 17205aa commit 5d7227a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Libraries/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ const Touchable = require('Touchable');
const createReactNativeComponentClass =
require('react/lib/createReactNativeComponentClass');
const merge = require('merge');
const mergeFast = require('mergeFast');

const stylePropType = StyleSheetPropType(TextStylePropTypes);

const viewConfig = {
validAttributes: merge(ReactNativeViewAttributes.UIView, {
validAttributes: mergeFast(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
numberOfLines: true,
ellipsizeMode: true,
Expand Down Expand Up @@ -189,7 +190,7 @@ const Text = React.createClass({
};
},
getInitialState: function(): Object {
return merge(Touchable.Mixin.touchableGetInitialState(), {
return mergeFast(Touchable.Mixin.touchableGetInitialState(), {
isHighlighted: false,
});
},
Expand Down Expand Up @@ -334,7 +335,7 @@ var RCTVirtualText = RCTText;

if (Platform.OS === 'android') {
RCTVirtualText = createReactNativeComponentClass({
validAttributes: merge(ReactNativeViewAttributes.UIView, {
validAttributes: mergeFast(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
}),
uiViewClassName: 'RCTVirtualText',
Expand Down

0 comments on commit 5d7227a

Please sign in to comment.