Glob.cc 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. }