Created
November 21, 2012 08:36
-
-
Save yenliangl/4123824 to your computer and use it in GitHub Desktop.
Improving performance of ifstream in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::ifstream file("test.txt", std::ios::in | std::ios::end); | |
std::size_t fileSize = file.tellg(); | |
std::vector<char> buffer(fileSize); | |
file.seekg(0, std::ios::beg); | |
file.read(buffer.data(), fileSize); | |
std::string str(buffer.begin(), buffer.end()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment