Revert "replace cached substr map with calling std::string::substr directly, which is faster."

This reverts commit 1e283087002bd37e314ee948a3ee44d26303db8b.
Revert "Revert "replace cached substr map with calling std::string::substr directly, which is faster.""

This reverts commit bf2c4bc99b8d4e8c0e14361c82cd4f622467b7b6.