Use StringRef::substr instead of std::string::substr to avoid using a free'd