FString optimization

This commit is contained in:
Markus Gans 2020-10-13 12:55:28 +02:00
parent 8d189e9ec4
commit 3c46dad798
8 changed files with 17 additions and 99 deletions

View File

@ -230,10 +230,10 @@ void debug (const finalcut::FApplication& TermApp)
<< debug_data.getTermType_SecDA() << "\r\n";
if ( ! ab_s.isEmpty() )
tcapString ("| The answerback String", ab_s);
tcapString ("| The answerback String", ab_s.c_str());
if ( ! sec_da.isEmpty() )
tcapString ("| The SecDA String", sec_da);
tcapString ("| The SecDA String", sec_da.c_str());
std::cout << "`------------------- debug -------------------\r\n";
}

View File

@ -1021,7 +1021,7 @@ void MyDialog::cb_view (const finalcut::FMenuItem* item)
view->setResizeable();
std::string line{""};
std::ifstream infile;
infile.open(file);
infile.open(file.c_str());
while ( ! infile.eof() && infile.good() )
{

View File

@ -355,7 +355,7 @@ void FApplication::setDarkTheme()
void FApplication::setLogFile (const FString& filename)
{
auto& log_stream = getStartOptions().logfile_stream;
log_stream.open(filename, std::ofstream::out);
log_stream.open(filename.c_str(), std::ofstream::out);
if ( log_stream.is_open() )
{
@ -834,10 +834,8 @@ bool FApplication::processDialogSwitchAccelerator() const
//----------------------------------------------------------------------
bool FApplication::processAccelerator (const FWidget* const& widget) const
{
bool accpt{false};
if ( ! widget || widget->getAcceleratorList().empty() )
return accpt;
return false;
for (auto&& item : widget->getAcceleratorList())
{
@ -854,15 +852,14 @@ bool FApplication::processAccelerator (const FWidget* const& widget) const
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
sendEvent (item.object, &a_ev);
accpt = a_ev.isAccepted();
break;
return a_ev.isAccepted();
}
if ( quit_now || app_exit_loop )
break;
}
return accpt;
return false;
}
//----------------------------------------------------------------------

View File

@ -476,20 +476,15 @@ bool FButtonGroup::directFocusRadioButton() const
if ( ! hasCheckedButton() || buttonlist.empty() )
return false;
bool found_checked{false};
for (auto&& item : buttonlist)
{
auto toggle_button = static_cast<FToggleButton*>(item);
if ( toggle_button->isChecked() )
{
found_checked = directFocusCheckedRadioButton(toggle_button);
break;
}
return directFocusCheckedRadioButton (toggle_button);
}
return found_checked;
return false;
}
//----------------------------------------------------------------------

View File

@ -790,7 +790,7 @@ void FFileDialog::cb_processActivate()
return ! entry.name.empty()
&& input
&& ! input.isNull()
&& std::strcmp(entry.name.c_str(), input) == 0
&& std::strcmp(entry.name.c_str(), input.c_str()) == 0
&& entry.directory;
}
);

View File

@ -1534,76 +1534,6 @@ FString operator + (const FString& s1, const FString& s2)
return tmp;
}
//----------------------------------------------------------------------
FString operator + (const FString& s, const wchar_t c)
{
FString tmp1{s};
wchar_t tmp2[2];
tmp2[0] = c;
tmp2[1] = L'\0';
tmp1._insert (tmp1.length, 1, tmp2);
return tmp1;
}
//----------------------------------------------------------------------
FString operator + (const std::wstring& s1, const FString& s2)
{
FString tmp{s1};
tmp._insert (tmp.length, s2.length, s2.wc_str());
return tmp;
}
//----------------------------------------------------------------------
FString operator + (const wchar_t s1[], const FString& s2)
{
FString tmp{s1};
tmp._insert (tmp.length, s2.length, s2.wc_str());
return tmp;
}
//----------------------------------------------------------------------
FString operator + (const std::string& s1, const FString& s2)
{
FString tmp{s1};
tmp._insert (tmp.length, s2.length, s2.wc_str());
return tmp;
}
//----------------------------------------------------------------------
FString operator + (const char s1[], const FString& s2)
{
FString tmp{s1};
tmp._insert (tmp.length, s2.length, s2.wc_str());
return tmp;
}
//----------------------------------------------------------------------
FString operator + (const wchar_t c, const FString& s)
{
FString tmp{c};
tmp._insert (1, s.length, s.wc_str());
return tmp;
}
//----------------------------------------------------------------------
FString operator + (const char c, const FString& s)
{
FString tmp{c};
tmp._insert (1, s.length, s.wc_str());
return tmp;
}
//----------------------------------------------------------------------
FString operator + (const FString& s, const char c)
{
FString tmp1{s};
wchar_t tmp2[2];
tmp2[0] = wchar_t(c & 0xff);
tmp2[1] = L'\0';
tmp1._insert (tmp1.length, 1, tmp2);
return tmp1;
}
//----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FString& s)
{

View File

@ -113,7 +113,10 @@ class FString
FString& operator << (const char);
template <typename NumT
, typename std::enable_if< std::is_integral<NumT>::value
&& ! std::is_same<NumT, bool>::value
&& ! std::is_pointer<NumT>::value
|| std::is_floating_point<NumT>::value
&& ! std::is_pointer<NumT>::value
, int>::type = 0 >
FString& operator << (const NumT);
@ -157,8 +160,6 @@ class FString
template <typename CharT>
bool operator > (const CharT&) const;
operator const char* () const { return c_str(); }
// Accessor
virtual FString getClassName() const;
@ -263,14 +264,6 @@ class FString
// Friend Non-member operator functions
friend FString operator + (const FString&, const FString&);
friend FString operator + (const FString&, const wchar_t);
friend FString operator + (const std::wstring&, const FString&);
friend FString operator + (const wchar_t[], const FString&);
friend FString operator + (const std::string&, const FString&);
friend FString operator + (const char[], const FString&);
friend FString operator + (const wchar_t, const FString&);
friend FString operator + (const char, const FString&);
friend FString operator + (const FString&, const char);
friend std::ostream& operator << (std::ostream&, const FString&);
friend std::istream& operator >> (std::istream&, FString& s);
@ -283,7 +276,10 @@ class FString
//----------------------------------------------------------------------
template <typename NumT
, typename std::enable_if< std::is_integral<NumT>::value
&& ! std::is_same<NumT, bool>::value
&& ! std::is_pointer<NumT>::value
|| std::is_floating_point<NumT>::value
&& ! std::is_pointer<NumT>::value
, int>::type >
inline FString& FString::operator << (const NumT val)
{

View File

@ -106,7 +106,7 @@ inline std::wstringbuf* FStringStream::rdbuf() const
//----------------------------------------------------------------------
inline FString FStringStream::str() const
{ return buffer.str(); }
{ return FString{buffer.str()}; }
// FStringStream non-member function