Skip to content

Commit 8f6521a

Browse files
davidaureliofacebook-github-bot
authored andcommitted
Don't pass std::string by pointer
Summary: @public Pass strings by mutable ref rather than pointer. Reviewed By: SidharthGuglani Differential Revision: D13236159 fbshipit-source-id: 04fd35e8a9e106ba8cdd71cfab31e8d90edaac9e
1 parent 32d5da2 commit 8f6521a

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Diff for: ReactCommon/yoga/yoga/YGNodePrint.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ namespace facebook {
1414
namespace yoga {
1515
typedef std::string string;
1616

17-
static void indent(string* base, uint32_t level) {
17+
static void indent(string& base, uint32_t level) {
1818
for (uint32_t i = 0; i < level; ++i) {
19-
base->append(" ");
19+
base.append(" ");
2020
}
2121
}
2222

@@ -25,7 +25,7 @@ static bool areFourValuesEqual(const std::array<YGValue, YGEdgeCount>& four) {
2525
YGValueEqual(four[0], four[3]);
2626
}
2727

28-
static void appendFormatedString(string* str, const char* fmt, ...) {
28+
static void appendFormatedString(string& str, const char* fmt, ...) {
2929
va_list args;
3030
va_start(args, fmt);
3131
va_list argsCopy;
@@ -35,11 +35,11 @@ static void appendFormatedString(string* str, const char* fmt, ...) {
3535
vsnprintf(buf.data(), buf.size(), fmt, argsCopy);
3636
va_end(argsCopy);
3737
string result = string(buf.begin(), buf.end() - 1);
38-
str->append(result);
38+
str.append(result);
3939
}
4040

4141
static void appendFloatOptionalIfDefined(
42-
string* base,
42+
string& base,
4343
const string key,
4444
const YGFloatOptional num) {
4545
if (!num.isUndefined()) {
@@ -48,12 +48,12 @@ static void appendFloatOptionalIfDefined(
4848
}
4949

5050
static void appendNumberIfNotUndefined(
51-
string* base,
51+
string& base,
5252
const string key,
5353
const YGValue number) {
5454
if (number.unit != YGUnitUndefined) {
5555
if (number.unit == YGUnitAuto) {
56-
base->append(key + ": auto; ");
56+
base.append(key + ": auto; ");
5757
} else {
5858
string unit = number.unit == YGUnitPoint ? "px" : "%%";
5959
appendFormatedString(
@@ -63,23 +63,23 @@ static void appendNumberIfNotUndefined(
6363
}
6464

6565
static void
66-
appendNumberIfNotAuto(string* base, const string& key, const YGValue number) {
66+
appendNumberIfNotAuto(string& base, const string& key, const YGValue number) {
6767
if (number.unit != YGUnitAuto) {
6868
appendNumberIfNotUndefined(base, key, number);
6969
}
7070
}
7171

7272
static void
73-
appendNumberIfNotZero(string* base, const string& str, const YGValue number) {
73+
appendNumberIfNotZero(string& base, const string& str, const YGValue number) {
7474
if (number.unit == YGUnitAuto) {
75-
base->append(str + ": auto; ");
75+
base.append(str + ": auto; ");
7676
} else if (!YGFloatsEqual(number.value, 0)) {
7777
appendNumberIfNotUndefined(base, str, number);
7878
}
7979
}
8080

8181
static void appendEdges(
82-
string* base,
82+
string& base,
8383
const string& key,
8484
const std::array<YGValue, YGEdgeCount>& edges) {
8585
if (areFourValuesEqual(edges)) {
@@ -93,7 +93,7 @@ static void appendEdges(
9393
}
9494

9595
static void appendEdgeIfNotUndefined(
96-
string* base,
96+
string& base,
9797
const string& str,
9898
const std::array<YGValue, YGEdgeCount>& edges,
9999
const YGEdge edge) {
@@ -102,7 +102,7 @@ static void appendEdgeIfNotUndefined(
102102
}
103103

104104
void YGNodeToString(
105-
std::string* str,
105+
std::string& str,
106106
YGNodeRef node,
107107
YGPrintOptions options,
108108
uint32_t level) {

Diff for: ReactCommon/yoga/yoga/YGNodePrint.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace facebook {
1313
namespace yoga {
1414

1515
void YGNodeToString(
16-
std::string* str,
16+
std::string& str,
1717
YGNodeRef node,
1818
YGPrintOptions options,
1919
uint32_t level);

Diff for: ReactCommon/yoga/yoga/Yoga.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ static void YGNodePrintInternal(
10571057
const YGNodeRef node,
10581058
const YGPrintOptions options) {
10591059
std::string str;
1060-
facebook::yoga::YGNodeToString(&str, node, options, 0);
1060+
facebook::yoga::YGNodeToString(str, node, options, 0);
10611061
YGLog(node, YGLogLevelDebug, str.c_str());
10621062
}
10631063

0 commit comments

Comments
 (0)