Don't pass `std::string` by pointer
Summary: @public Pass strings by mutable ref rather than pointer. Reviewed By: SidharthGuglani Differential Revision: D13439613 fbshipit-source-id: ea889abe0fe8ec44ae02f13c1d9a10c0dbfdbcf1
This commit is contained in:
Родитель
206705892f
Коммит
a816c0321c
|
@ -14,9 +14,9 @@ namespace facebook {
|
|||
namespace yoga {
|
||||
typedef std::string string;
|
||||
|
||||
static void indent(string* base, uint32_t level) {
|
||||
static void indent(string& base, uint32_t level) {
|
||||
for (uint32_t i = 0; i < level; ++i) {
|
||||
base->append(" ");
|
||||
base.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ static bool areFourValuesEqual(const std::array<YGValue, YGEdgeCount>& four) {
|
|||
YGValueEqual(four[0], four[3]);
|
||||
}
|
||||
|
||||
static void appendFormatedString(string* str, const char* fmt, ...) {
|
||||
static void appendFormatedString(string& str, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
va_list argsCopy;
|
||||
|
@ -35,11 +35,11 @@ static void appendFormatedString(string* str, const char* fmt, ...) {
|
|||
vsnprintf(buf.data(), buf.size(), fmt, argsCopy);
|
||||
va_end(argsCopy);
|
||||
string result = string(buf.begin(), buf.end() - 1);
|
||||
str->append(result);
|
||||
str.append(result);
|
||||
}
|
||||
|
||||
static void appendFloatOptionalIfDefined(
|
||||
string* base,
|
||||
string& base,
|
||||
const string key,
|
||||
const YGFloatOptional num) {
|
||||
if (!num.isUndefined()) {
|
||||
|
@ -48,12 +48,12 @@ static void appendFloatOptionalIfDefined(
|
|||
}
|
||||
|
||||
static void appendNumberIfNotUndefined(
|
||||
string* base,
|
||||
string& base,
|
||||
const string key,
|
||||
const YGValue number) {
|
||||
if (number.unit != YGUnitUndefined) {
|
||||
if (number.unit == YGUnitAuto) {
|
||||
base->append(key + ": auto; ");
|
||||
base.append(key + ": auto; ");
|
||||
} else {
|
||||
string unit = number.unit == YGUnitPoint ? "px" : "%%";
|
||||
appendFormatedString(
|
||||
|
@ -63,24 +63,23 @@ static void appendNumberIfNotUndefined(
|
|||
}
|
||||
|
||||
static void
|
||||
appendNumberIfNotAuto(string* base, const string& key, const YGValue number) {
|
||||
appendNumberIfNotAuto(string& base, const string& key, const YGValue number) {
|
||||
if (number.unit != YGUnitAuto) {
|
||||
appendNumberIfNotUndefined(base, key, number);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
appendNumberIfNotZero(string* base, const string& str, const YGValue number) {
|
||||
|
||||
appendNumberIfNotZero(string& base, const string& str, const YGValue number) {
|
||||
if (number.unit == YGUnitAuto) {
|
||||
base->append(str + ": auto; ");
|
||||
base.append(str + ": auto; ");
|
||||
} else if (!YGFloatsEqual(number.value, 0)) {
|
||||
appendNumberIfNotUndefined(base, str, number);
|
||||
}
|
||||
}
|
||||
|
||||
static void appendEdges(
|
||||
string* base,
|
||||
string& base,
|
||||
const string& key,
|
||||
const std::array<YGValue, YGEdgeCount>& edges) {
|
||||
if (areFourValuesEqual(edges)) {
|
||||
|
@ -94,7 +93,7 @@ static void appendEdges(
|
|||
}
|
||||
|
||||
static void appendEdgeIfNotUndefined(
|
||||
string* base,
|
||||
string& base,
|
||||
const string& str,
|
||||
const std::array<YGValue, YGEdgeCount>& edges,
|
||||
const YGEdge edge) {
|
||||
|
@ -103,7 +102,7 @@ static void appendEdgeIfNotUndefined(
|
|||
}
|
||||
|
||||
void YGNodeToString(
|
||||
std::string* str,
|
||||
std::string& str,
|
||||
YGNodeRef node,
|
||||
YGPrintOptions options,
|
||||
uint32_t level) {
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace facebook {
|
|||
namespace yoga {
|
||||
|
||||
void YGNodeToString(
|
||||
std::string* str,
|
||||
std::string& str,
|
||||
YGNodeRef node,
|
||||
YGPrintOptions options,
|
||||
uint32_t level);
|
||||
|
|
|
@ -1060,7 +1060,7 @@ static void YGNodePrintInternal(
|
|||
const YGNodeRef node,
|
||||
const YGPrintOptions options) {
|
||||
std::string str;
|
||||
facebook::yoga::YGNodeToString(&str, node, options, 0);
|
||||
facebook::yoga::YGNodeToString(str, node, options, 0);
|
||||
YGLog(node, YGLogLevelDebug, str.c_str());
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче