Added the move constructor to cString for better performance

This commit is contained in:
Klaus Schmidinger 2024-01-20 13:59:55 +01:00
parent 88b1e30494
commit 5d984b606e
4 changed files with 16 additions and 3 deletions

View File

@ -2560,6 +2560,7 @@ Markus Ehrnsperger <markus.ehrnsperger@googlemail.com>
for making using a dummy OSD if no OSD provider is available not be considered an error
any more
for removing syslog calls in child process after fork()
for adding the move constructor to cString for better performance
Werner Färber <w.faerber@gmx.de>
for reporting a bug in handling the cPluginManager::Active() result when pressing

View File

@ -9863,7 +9863,7 @@ Video Disk Recorder Revision History
- The recording info of the default skins now shows the frame parameters of the
recording at the end of the description (if such information is available).
2024-01-19:
2024-01-20:
- Changed installing config files to handle potentially broken 'cp -n'.
- Fixed height calculation in progress display (thanks to Matthias Senzel).
@ -9877,3 +9877,5 @@ Video Disk Recorder Revision History
(thanks to Matthias Senzel).
- Fixed an unnecessary double display of menu items in the Recordings menu (thanks to
Matthias Senzel).
- Added the move constructor to cString for better performance (thanks to Markus
Ehrnsperger).

10
tools.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: tools.c 5.8 2023/12/29 10:24:29 kls Exp $
* $Id: tools.c 5.9 2024/01/20 13:59:55 kls Exp $
*/
#include "tools.h"
@ -1106,6 +1106,14 @@ cString &cString::operator=(const cString &String)
return *this;
}
cString &cString::operator=(cString &&String)
{
free(s);
s = String.s;
String.s = NULL;
return *this;
}
cString &cString::operator=(const char *String)
{
if (s == String)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: tools.h 5.7 2023/12/29 10:21:59 kls Exp $
* $Id: tools.h 5.8 2024/01/20 13:59:55 kls Exp $
*/
#ifndef __TOOLS_H
@ -182,11 +182,13 @@ public:
cString(const char *S = NULL, bool TakePointer = false);
cString(const char *S, const char *To); ///< Copies S up to To (exclusive). To must be a valid pointer into S. If To is NULL, everything is copied.
cString(const cString &String);
cString(cString &&String): s(String.s) { String.s = NULL; }
virtual ~cString();
operator const void * () const { return s; } // to catch cases where operator*() should be used
operator const char * () const { return s; } // for use in (const char *) context
const char * operator*() const { return s; } // for use in (const void *) context (printf() etc.)
cString &operator=(const cString &String);
cString &operator=(cString &&String);
cString &operator=(const char *String);
cString &Append(const char *String);
cString &Append(char c);