Skip to content

Commit

Permalink
Fix GitHub issue #180: Performance using Unpacker
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Sep 12, 2019
1 parent 7b6a599 commit 31884e0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
5 changes: 1 addition & 4 deletions Src/MergeDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,7 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical,

String temp = m_tempFiles[nBuffer].GetPath();
if (temp.empty())
{
temp = m_tempFiles[nBuffer].CreateFromFile(m_filePaths.GetPath(nBuffer),
tnames[nBuffer]);
}
temp = m_tempFiles[nBuffer].Create(tnames[nBuffer]);
if (temp.empty())
return RESCAN_TEMP_ERR;
}
Expand Down
34 changes: 0 additions & 34 deletions Src/TempFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,6 @@ String TempFile::Create(const String& prefix, const String& ext)
return temp;
}

/**
* @brief Create a temporary file from existing file's contents.
* This function creates a temporary file to temp folder and copies
* given file's contents to there.
* @param [in] filepath Full path to existing file.
* @param [in] prefix Prefix for the temporary filename.
* @return Full path to the temporary file.
*/
String TempFile::CreateFromFile(const String& filepath, const String& prefix)
{
String temp = env::GetTemporaryPath();
if (temp.empty())
{
return _T("");
}

String pref = prefix;
if (pref.empty())
pref = _T("wmtmp");

temp = env::GetTemporaryFileName(temp, pref, nullptr);
if (!temp.empty())
{
// Scratchpads don't have a file to copy.
m_path = temp;

if (::CopyFileW(TFile(filepath).wpath().c_str(), temp.c_str(), FALSE))
{
::SetFileAttributes(temp.c_str(), FILE_ATTRIBUTE_NORMAL);
}
}
return temp;
}

/**
* @brief Delete the temporary file, if it exists.
* @return true if there was no error.
Expand Down

0 comments on commit 31884e0

Please sign in to comment.