소스 검색

Fix performance issue with getting version from zlib.h

Some zlib.h files have ZLIB_VERSION "1.2.3.3" with 4 numbers instead of 3.
The regex is changed to grab the first 3 numbers.
It was slow because if it failed to find that string near the top of the file,
where it usually is, it would read the entire file.
Clinton Stimpson 15 년 전
부모
커밋
5850b8b79a
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      Modules/FindZLIB.cmake

+ 1 - 1
Modules/FindZLIB.cmake

@@ -38,7 +38,7 @@ MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
 
 IF (ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
     FILE(READ "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H)
-    STRING(REGEX REPLACE ".*#define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+)\".*" "\\1.\\2.\\3" ZLIB_VERSION_STRING "${ZLIB_H}")
+    STRING(REGEX REPLACE ".*#define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1.\\2.\\3" ZLIB_VERSION_STRING "${ZLIB_H}")
 ENDIF()
 
 # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if