소스 검색

IsOff: Use the length for the string construction

No need to waste the calculation and force the string to call strlen
again.
Ben Boeckel 12 년 전
부모
커밋
9270aa9a2d
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      Source/cmSystemTools.cxx

+ 3 - 2
Source/cmSystemTools.cxx

@@ -406,11 +406,12 @@ bool cmSystemTools::IsNOTFOUND(const char* val)
 
 bool cmSystemTools::IsOff(const char* val)
 {
-  if (!val || strlen(val) == 0)
+  if (!val || !*val)
     {
     return true;
     }
-  std::basic_string<char> v = val;
+  size_t len = val ? strlen(val) : 0;
+  std::basic_string<char> v(val, len);
 
   for(std::basic_string<char>::iterator c = v.begin();
       c != v.end(); c++)