Fabric: Getting rid of many auto &&

Summary:
@public
After reading about move-semantic and rvalue refs I realized that we (I) definitely overuse  `auto &&` (aka universal reference) construction. Even if this is harmless, does not look good and idiomatic.
Whenever I used that from a semantical point of view I always meant  "I need an alias for this" which is actually "read-only reference" which is `const auto &`.
This is also fit good to our policy where "everything is const (immutable) by default".
Hence I change that to how it should be.

Reviewed By: fkgozali

Differential Revision: D8475637

fbshipit-source-id: 0a691ededa0e798db8ffa053bff0f400913ab7b8
This commit is contained in:
Valentin Shergin
2018-06-22 07:28:36 -07:00
committed by Facebook Github Bot
parent c674303dfd
commit eabf29e320
14 changed files with 45 additions and 45 deletions

View File

@@ -30,7 +30,7 @@ static UIActivityIndicatorViewStyle convertActivityIndicatorViewStyle(const Acti
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithFrame:self.bounds];
_activityIndicatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
auto &&defaultProps = ActivityIndicatorViewProps();
const auto &defaultProps = ActivityIndicatorViewProps();
if (defaultProps.animating) {
[_activityIndicatorView startAnimating];

View File

@@ -26,7 +26,7 @@ using namespace facebook::react;
action:@selector(onChange:)
forControlEvents:UIControlEventValueChanged];
auto &&defaultProps = SwitchProps();
const auto &defaultProps = SwitchProps();
_switchView.on = defaultProps.value;

View File

@@ -191,7 +191,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action
- (void)_registerTouches:(NSSet<UITouch *> *)touches
{
for (UITouch *touch in touches) {
auto &&activeTouch = CreateTouchWithUITouch(touch, _rootComponentView);
auto activeTouch = CreateTouchWithUITouch(touch, _rootComponentView);
activeTouch.touch.identifier = _identifierPool.dequeue();
_activeTouches.emplace(touch, activeTouch);
}
@@ -207,7 +207,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action
- (void)_unregisterTouches:(NSSet<UITouch *> *)touches
{
for (UITouch *touch in touches) {
auto &&activeTouch = _activeTouches[touch];
const auto &activeTouch = _activeTouches[touch];
_identifierPool.enqueue(activeTouch.touch.identifier);
_activeTouches.erase(touch);
}
@@ -221,7 +221,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action
BOOL isEndishEventType = eventType == RCTTouchEventTypeTouchEnd || eventType == RCTTouchEventTypeTouchCancel;
for (UITouch *touch in touches) {
auto &&activeTouch = _activeTouches[touch];
const auto &activeTouch = _activeTouches[touch];
if (!activeTouch.eventEmitter) {
continue;
@@ -232,7 +232,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action
uniqueEventEmitter.insert(activeTouch.eventEmitter);
}
for (auto &&pair : _activeTouches) {
for (const auto &pair : _activeTouches) {
if (!pair.second.eventEmitter) {
continue;
}
@@ -247,10 +247,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action
event.touches.insert(pair.second.touch);
}
for (auto &&eventEmitter : uniqueEventEmitter) {
for (const auto &eventEmitter : uniqueEventEmitter) {
event.targetTouches.clear();
for (auto &&pair : _activeTouches) {
for (const auto &pair : _activeTouches) {
if (pair.second.eventEmitter == eventEmitter) {
event.targetTouches.insert(pair.second.touch);
}