46e885f5bd5b3b897bbc8df613c7287c2a457e6bd7aa4d9459d0b45672010524bf51e66fc6ab868e0a4ebf119c00e71a13eeaa4b79985c632be5dc1f4f4e97 539 B

12345678910111213141516171819202122
  1. #include "Glob.hh"
  2. #ifdef __wasm32__
  3. extern "C" bool wasm_regex_match(const char *s, const char *regex);
  4. #endif
  5. Glob::Glob(std::string raw) {
  6. mRaw = raw;
  7. mHash = std::hash<std::string>()(raw);
  8. #ifndef __wasm32__
  9. mRegex = std::regex(raw);
  10. #endif
  11. }
  12. bool Glob::isIgnored(std::string relative_path) const {
  13. // Use native JS regex engine for wasm to reduce binary size.
  14. #ifdef __wasm32__
  15. return wasm_regex_match(relative_path.c_str(), mRaw.c_str());
  16. #else
  17. return std::regex_match(relative_path, mRegex);
  18. #endif
  19. }