Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNative::Clear() → CNative::shrink_to_empty() に名前変更する #778

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sakura_core/cmd/CViewCommander_Clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void CViewCommander::Command_CUT( void )
ErrorBeep();
return;
}
cmemBuf.Clear();
cmemBuf.shrink_to_empty();

/* カーソル位置または選択エリアを削除 */
m_pCommanderView->DeleteData( true );
Expand Down Expand Up @@ -116,7 +116,7 @@ void CViewCommander::Command_COPY(
return;
}
}
cmemBuf.Clear();
cmemBuf.shrink_to_empty();

/* 選択範囲の後片付け */
if( !bIgnoreLockAndDisable ){
Expand Down
4 changes: 2 additions & 2 deletions sakura_core/cmd/CViewCommander_Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void CViewCommander::Command_BASE64DECODE( void )
if( !bret ){
return;
}
ctextBuf.Clear();
ctextBuf.shrink_to_empty();

/* 保存ダイアログ モーダルダイアログの表示 */
TCHAR szPath[_MAX_PATH] = _T("");
Expand Down Expand Up @@ -276,7 +276,7 @@ void CViewCommander::Command_UUDECODE( void )
return;
}
decoder.CopyFilename( szPath );
ctextBuf.Clear();
ctextBuf.shrink_to_empty();

/* 保存ダイアログ モーダルダイアログの表示 */
if( !GetDocument()->m_cDocFileOperation.SaveFileDialog( szPath ) ){
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/cmd/CViewCommander_File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ BOOL CViewCommander::Command_PUTFILE(
pcUtf16->GetBom(cmemBom._GetMemory());
cMem2.AppendNativeData(cmemBom);
cMem2.AppendNativeData(cMem);
cMem.Clear();
cMem.shrink_to_empty();
pConvBuffer = &cMem2;
}else{
pConvBuffer = &cMem;
Expand Down
6 changes: 4 additions & 2 deletions sakura_core/mem/CNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#include "StdAfx.h"
#include "CNative.h"

//! 空っぽにする
void CNative::Clear()
/*
バッファサイズを縮小して空にする。
*/
void CNative::shrink_to_empty()
{
this->SetRawData("",0);
}
10 changes: 8 additions & 2 deletions sakura_core/mem/CNative.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ class CNative : protected CMemory{
const CMemory* _GetMemory() const{ return static_cast<const CMemory*>(this); }

public:
//汎用
void Clear(); //!< 空っぽにする
/*!
バッファサイズを縮小して空にする。

1. std::basic_string::shrink_to_fit() と同様にメモリサイズを縮小させる。
(メモリサイズを縮小する際にメモリの再確保が行われる。)
2. それに加えてデータを空にする。
*/
void shrink_to_empty();
};

#include "mem/CNativeA.h"
Expand Down
4 changes: 2 additions & 2 deletions sakura_core/view/CEditView_Command_New.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void CEditView::InsertData_CEditView(
bHintNext = true;
}
StringToOpeLineData( cMem.GetStringPtr(), cMem.GetStringLength(), insData, opeSeq );
cMem.Clear();
cMem.shrink_to_empty();
nColumnFrom = LineIndexToColumn( pcLayout, nIdxFrom );
}
else{
Expand All @@ -181,7 +181,7 @@ void CEditView::InsertData_CEditView(
}
cMem.AppendString( pData, nDataLen );
StringToOpeLineData( cMem.GetStringPtr(), cMem.GetStringLength(), insData, opeSeq );
cMem.Clear();
cMem.shrink_to_empty();
}else{
StringToOpeLineData( pData, nDataLen, insData, opeSeq );
}
Expand Down