27
27
28
28
namespace WeexCore {
29
29
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" ;
36
36
37
37
template <typename T>
38
38
inline std::string to_string (const T &n) {
@@ -108,7 +108,7 @@ namespace WeexCore {
108
108
inline float transferWx (const std::string &stringWithWXPostfix, const float &viewport) {
109
109
std::string temp = stringWithWXPostfix;
110
110
if (endWidth (stringWithWXPostfix, WX)) {
111
- temp = stringWithWXPostfix.substr (0 , stringWithWXPostfix.size () - WX. size ( ));
111
+ temp = stringWithWXPostfix.substr (0 , stringWithWXPostfix.size () - strlen (WX ));
112
112
}
113
113
float f = getFloat (temp.c_str ());
114
114
float density = getFloat (WXCoreEnvironment::getInstance ()->GetOption (SCALE).c_str ());
@@ -127,7 +127,7 @@ namespace WeexCore {
127
127
if (endWidth (src, WX)) {
128
128
ret = getFloat (transferWx (src, viewport), viewport, round_off_deviation);
129
129
} 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);
131
131
} else {
132
132
ret = getFloat (src, viewport, round_off_deviation);
133
133
}
0 commit comments