Skip to content

Commit

Permalink
Merge pull request #250 from C-53/bugfix-msvc2015-stream-buffer
Browse files Browse the repository at this point in the history
[Fix] Unbuffered streams causing poor performance with MSVC 2015
  • Loading branch information
rikyoz authored Oct 6, 2024
2 parents bec6a22 + 1464c11 commit 003b7a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/internal/cfileinstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ CFileInStream::CFileInStream( const fs::path& filePath ) : CStdInStream( mFileSt
* Note: we need to do this before and after opening the file (https://stackoverflow.com/a/59161297/3497024). */
mFileStream.rdbuf()->pubsetbuf( nullptr, 0 );
openFile( filePath );
// Unbuffered streams are slow for Visual Studio 2015
#if !defined(_MSC_VER) || _MSC_VER != 1900
mFileStream.rdbuf()->pubsetbuf( nullptr, 0 );
#endif
}

void CFileInStream::openFile( const fs::path& filePath ) {
Expand Down
3 changes: 3 additions & 0 deletions src/internal/cfileoutstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ CFileOutStream::CFileOutStream( fs::path filePath, bool createAlways )
throw BitException( "Failed to open the output file", last_error_code(), path_to_tstring( mFilePath ) );
#endif
}
// Unbuffered streams are slow for Visual Studio 2015
#if !defined(_MSC_VER) || _MSC_VER != 1900
mFileStream.rdbuf()->pubsetbuf( nullptr, 0 );
#endif
}

auto CFileOutStream::fail() const -> bool {
Expand Down

0 comments on commit 003b7a0

Please sign in to comment.