Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit 992d3ee

Browse files
wqyfavorjianhan-he
authored andcommitted
[Core] Remove C++ static initializers. (#2355)
1 parent 5805330 commit 992d3ee

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

weex_core/Source/base/core_constants.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include <string>
2424

25-
const std::string OS_Android = "android";
26-
const std::string OS_iOS = "iOS";
25+
constexpr char OS_Android[] = "android";
26+
constexpr char OS_iOS[] = "iOS";
2727

2828
#endif //WEEXV8_CONSTANTSNAME_H

weex_core/Source/core/common/view_utils.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727

2828
namespace WeexCore {
2929

30-
const std::string WX("wx");
31-
const std::string PX("px");
32-
const std::string UNDEFINE("undefined");
33-
const std::string SCALE("scale");
34-
const std::string AUTO_UNIT("auto");
35-
const std::string NONE("none");
30+
constexpr char WX[] = "wx";
31+
constexpr char PX[] = "px";
32+
constexpr char UNDEFINE[] = "undefined";
33+
constexpr char SCALE[] = "scale";
34+
constexpr char AUTO_UNIT[] = "auto";
35+
constexpr char NONE[] = "none";
3636

3737
template<typename T>
3838
inline std::string to_string(const T &n) {
@@ -108,7 +108,7 @@ namespace WeexCore {
108108
inline float transferWx(const std::string &stringWithWXPostfix, const float &viewport) {
109109
std::string temp = stringWithWXPostfix;
110110
if (endWidth(stringWithWXPostfix, WX)) {
111-
temp = stringWithWXPostfix.substr(0, stringWithWXPostfix.size() - WX.size());
111+
temp = stringWithWXPostfix.substr(0, stringWithWXPostfix.size() - strlen(WX));
112112
}
113113
float f = getFloat(temp.c_str());
114114
float density = getFloat(WXCoreEnvironment::getInstance()->GetOption(SCALE).c_str());
@@ -127,7 +127,7 @@ namespace WeexCore {
127127
if (endWidth(src, WX)) {
128128
ret = getFloat(transferWx(src, viewport), viewport, round_off_deviation);
129129
} else if (endWidth(src, PX)) {
130-
ret = getFloat(src.substr(0, src.size() - PX.size()), viewport, round_off_deviation);
130+
ret = getFloat(src.substr(0, src.size() - strlen(PX)), viewport, round_off_deviation);
131131
} else {
132132
ret = getFloat(src, viewport, round_off_deviation);
133133
}

0 commit comments

Comments
 (0)