react-native/Libraries
Liu Zhanhong 6b29fe78c4 Avoid creating a new Path instance for performance
Summary:
New a Path instance will cause a slice call to exist path.

```js
// react-native/Libraries/ART/ARTSerializablePath.js
if (path instanceof SerializablePath) {
  this.path = path.path.slice(0);
}
```

Most of d3's APIs can set context when we don't want to use d3's build-in path object. And in RN envirenment, we must use RN's path instance. So we can use RN's path as a context in d3 avoiding doing conversions from svg's path string to arrays. But with existing code, when Shape receive a `d` proprety, it new a path instance and will cause calling slice in a very large array.

Typical usage is as follows

```js
import React from 'react';
import { View, ART } from 'react-native';
import { line } from 'd3-shape';
import { scaleLinear } from 'd3-scale';

const { Path, Surface, Shape } = ART;
const width = 360;
const height = 300;
const data = [5,2,7,6,9,1,8,4,3];
const x = scaleLinear().range([0, width]).domain([0, data.length]);
const y = scaleLinear().range([height, 0]).domain([0, 9]);
const myline = line()
    .x(function(d, i) {
      return x(i);
    })
    .y(function(d) { return y(d); });

// use RN's ART Path
const path = Path();
myline.context(path)(data);

class TestArt extends React.Component {
  render() {
    return (
      <View>
        <Surface width={width} height={height}>
          <Shape
            stroke="red"
            d={
              // use RN's ART Path
              path
              // use d3's path
              // myline(data)
            }
          />
        </Surface>
      </View>
    );
  }
}
```
Closes https://github.com/facebook/react-native/pull/14551

Differential Revision: D5398653

Pulled By: javache

fbshipit-source-id: 1264acfb8844b60584604a664e0474f9e212d1d1
2017-07-11 11:18:56 -07:00
..
ART Avoid creating a new Path instance for performance 2017-07-11 11:18:56 -07:00
ActionSheetIOS Enable -Wimplicit-retain-self en sync warning config for all projects 2017-03-23 15:01:34 -07:00
AdSupport Update AdSupportIOS.js 2017-04-28 06:34:21 -07:00
Alert Export Alert's type ButtonsArray for external use 2017-03-06 12:44:47 -08:00
Animated remove disableAutomock from jest tests (new default) @bypass-lint 2017-06-13 15:04:09 -07:00
AppState Added stubs for some native modules 2017-06-01 08:31:19 -07:00
BatchedBridge Make a method used externaly (in a test) public 2017-07-03 07:53:58 -07:00
BugReporting Patch up for future React Sync 2017-02-08 14:50:43 -08:00
CameraRoll Update remaining PropTypes references 2017-06-12 16:03:09 -07:00
Components Clarity in pagingEnabled description for ScrollView 2017-07-10 17:46:14 -07:00
Core Remove unused RCTDebugComponentOwnership 2017-07-07 12:04:04 -07:00
EventEmitter Allow lazy modules registration with the BatchedBridge 2017-06-06 07:07:19 -07:00
Experimental Support for preventing swipe left or swipe right 2017-07-07 20:03:20 -07:00
Geolocation fix error caused by first argument short when calling warning function 2017-06-22 08:46:43 -07:00
Image Fixed ImageBackground could't be wrapped by Touchable* component 2017-07-10 05:03:25 -07:00
Inspector Use fixed point in inspector 2017-07-06 14:52:28 -07:00
Interaction Move jest to version 20 2017-06-14 12:48:22 -07:00
JSInspector Add Network agent 2016-11-02 12:29:15 -07:00
LayoutAnimation Fix prop-types warning in LayoutAnimation 2017-05-12 15:06:17 -07:00
Linking Add newly recommended method for RCTLinkingManager due to deprecation 2017-05-25 11:31:23 -07:00
LinkingIOS Add newly recommended method for RCTLinkingManager due to deprecation 2017-05-25 11:31:23 -07:00
Lists Enforce Prettier for @format 2017-07-10 15:37:36 -07:00
Modal iOS `presentationStyle` Modal Appearance 2017-06-20 19:22:57 -07:00
NativeAnimation Native Animated - Support Animated.loop on iOS 2017-05-26 03:30:33 -07:00
Network Fix RCTNetworking error message 2017-07-11 09:10:20 -07:00
Performance Remove unused RCTRenderingPerf 2017-06-22 09:01:04 -07:00
PermissionsAndroid Include Create React Native App in Getting Started 2017-04-26 07:16:18 -07:00
PushNotificationIOS Rename _remoteNotificationCompleteCalllbackCalled to _remoteNotificationCompleteCallbackCalled 2017-07-11 11:06:21 -07:00
RCTTest Fixing compiler warning 2017-06-05 23:30:34 -07:00
ReactNative Support native ViewManager inheritance on iOS 2017-07-10 16:01:12 -07:00
Renderer React sync for revisions 4aea7c3...cb32253 2017-06-26 15:15:59 -07:00
Sample Fix missing RCTBridgeModule.h 2017-01-31 11:13:50 -08:00
Settings Enable -Wimplicit-retain-self en sync warning config for all projects 2017-03-23 15:01:34 -07:00
Share Flowify Process Color 2017-04-26 11:31:56 -07:00
Storage correctly order ASyncStorage 2017-02-21 15:18:40 -08:00
StyleSheet Refined type for `display` style property 2017-06-20 17:16:46 -07:00
Text Replace React.createClass with create-react-class 2017-07-07 14:36:01 -07:00
Utilities remove disableAutomock from jest tests (new default) @bypass-lint 2017-06-13 15:04:09 -07:00
Vibration Enable -Wimplicit-retain-self en sync warning config for all projects 2017-03-23 15:01:34 -07:00
WebSocket Make startup errors in the websocket executor invalidate the bridge 2017-06-22 08:37:13 -07:00
polyfills Move polyfills to react-native 2017-07-11 03:47:16 -07:00
react-native RN: Expose `unstable_batchedUpdates` on react-native 2017-06-21 00:47:08 -07:00
vendor RN: Remove lodash (Attempt 2) 2017-06-16 18:15:17 -07:00
Promise.js Don't require prettyFormat in every single bundle. 2017-06-16 04:31:56 -07:00
promiseRejectionIsError.js RN: Cleanup OSS JS & Flow Declarations 2016-11-20 17:58:29 -08:00