rbutil: Use references to avoid creating temporary objects.

Get rid of some unnecessary object creating / copying by using
references.

Change-Id: Ia44e34f6f66d230caa9af7ef7c0eca73be12de2a
This commit is contained in:
Dominik Riebeling 2022-04-17 12:26:43 +02:00
parent 8c55ce62b9
commit 62108a9613
14 changed files with 24 additions and 25 deletions

View file

@ -36,9 +36,9 @@ class TTSBase : public EncTtsSettingInterface
TTSBase(QObject *parent);
//! Child class should generate a clip
virtual TTSStatus voice(QString text,QString wavfile, QString* errStr) =0;
virtual TTSStatus voice(const QString& text, const QString& wavfile, QString* errStr) = 0;
//! Child class should do startup
virtual bool start(QString *errStr) =0;
virtual bool start(QString *errStr) = 0;
//! child class should stop
virtual bool stop() =0;

View file

@ -171,7 +171,7 @@ void TTSCarbon::saveSettings(void)
/** @brief create wav file from text using the selected TTS voice.
*/
TTSStatus TTSCarbon::voice(QString text, QString wavfile, QString* errStr)
TTSStatus TTSCarbon::voice(const QString& text, const QString& wavfile, QString* errStr)
{
TTSStatus status = NoError;
OSErr error;

View file

@ -39,7 +39,7 @@ class TTSCarbon : public TTSBase
TTSCarbon(QObject *parent = NULL);
//! Child class should generate a clip
TTSStatus voice(QString text, QString wavfile, QString* errStr);
TTSStatus voice(const QString& text, const QString& wavfile, QString* errStr);
//! Child class should do startup
bool start(QString *errStr);
//! child class should stop

View file

@ -80,7 +80,7 @@ bool TTSExes::start(QString *errStr)
}
}
TTSStatus TTSExes::voice(QString text, QString wavfile, QString *errStr)
TTSStatus TTSExes::voice(const QString& text, const QString& wavfile, QString *errStr)
{
(void) errStr;
QString execstring;

View file

@ -35,7 +35,7 @@ class TTSExes : public TTSBase
Q_OBJECT
public:
TTSExes(QObject* parent=nullptr);
TTSStatus voice(QString text, QString wavfile, QString *errStr);
TTSStatus voice(const QString& text, const QString& wavfile, QString *errStr);
bool start(QString *errStr);
bool stop() {return true;}
QString voiceVendor(void) { return QString(); }

View file

@ -182,7 +182,7 @@ bool TTSFestival::stop()
return true;
}
TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
TTSStatus TTSFestival::voice(const QString& text, const QString& wavfile, QString* errStr)
{
LOG_INFO() << "Voicing" << text << "->" << wavfile;

View file

@ -40,7 +40,7 @@ class TTSFestival : public TTSBase
~TTSFestival();
bool start(QString *errStr);
bool stop();
TTSStatus voice(QString text,QString wavfile, QString *errStr);
TTSStatus voice(const QString& text, const QString& wavfile, QString *errStr);
QString voiceVendor(void) { return QString(); }
Capabilities capabilities();

View file

@ -228,7 +228,7 @@ QStringList TTSSapi::getVoiceList(QString language)
TTSStatus TTSSapi::voice(QString text,QString wavfile, QString *errStr)
TTSStatus TTSSapi::voice(const QString& text, const QString& wavfile, QString *errStr)
{
(void) errStr;
QString query = "SPEAK\t"+wavfile+"\t"+text;

View file

@ -38,7 +38,7 @@ class TTSSapi : public TTSBase
public:
TTSSapi(QObject* parent=nullptr);
TTSStatus voice(QString text,QString wavfile, QString *errStr);
TTSStatus voice(const QString& text, const QString& wavfile, QString *errStr);
bool start(QString *errStr);
bool stop();
QString voiceVendor(void);

View file

@ -102,7 +102,7 @@ void Uninstaller::uninstall(void)
}
// for speed reasons update log file only at the end.
installlog.beginGroup(uninstallSections.at(i));
for (auto file : deletedItems)
for (const auto& file : deletedItems)
{
installlog.remove(file);
}

View file

@ -62,7 +62,7 @@
#endif
// recursive function to delete a dir with files
bool Utils::recursiveRmdir( const QString &dirName )
bool Utils::recursiveRmdir(const QString &dirName)
{
QString dirN = dirName;
QDir dir(dirN);

View file

@ -96,7 +96,7 @@ bool VoiceFileCreator::createVoiceFile()
// header (4 bytes): cookie = 9a, version = 06, targetid, options
// subheader for each user. Only "core" for now.
// subheader (6 bytes): count (2bytes), size (2bytes), offset (2bytes)
if(buf[0] != (char)0x9a || buf[1] != 0x06 || buf[2] != m_targetid) {
if(buf[0] != '\x9a' || buf[1] != '\x06' || buf[2] != m_targetid) {
emit logItem(tr("Extracted voice strings incompatible"), LOGINFO);
}
else {
@ -121,14 +121,14 @@ bool VoiceFileCreator::createVoiceFile()
QTemporaryFile voicefontlist;
voicefontlist.open();
m_filename = voicefontlist.fileName();
for(int i = 0; i < voicestrings.size(); ++i) {
for(auto key : voicestrings.keys()) {
QByteArray qba;
qba = QString("id: %1_%2\n")
.arg(voicestrings.keys().at(i) < 0x8000 ? "LANG" : "VOICE")
.arg(voicestrings.keys().at(i)).toUtf8();
.arg(key < 0x8000 ? "LANG" : "VOICE")
.arg(key).toUtf8();
voicefontlist.write(qba);
qba = QString("voice: \"%1\"\n").arg(
voicestrings[voicestrings.keys().at(i)]).toUtf8();
voicestrings[key]).toUtf8();
voicefontlist.write(qba);
}
voicefontlist.close();

View file

@ -37,13 +37,12 @@ class ZipInstaller : public QObject
Q_OBJECT
public:
ZipInstaller(QObject* parent);
~ZipInstaller(){}
void install(void);
void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;}
void setUrl(QString url){m_urllist = QStringList(url);}
void setUrl(QStringList url) { m_urllist = url; }
void setMountPoint(QString& mountpoint) {m_mountpoint = mountpoint;}
void setUrl(QString& url){m_urllist = QStringList(url);}
void setUrl(QStringList& url) { m_urllist = url; }
void setLogSection(QString name) {m_loglist = QStringList(name);}
void setLogSection(QStringList name) { m_loglist = name; }
void setLogSection(QStringList& name) { m_loglist = name; }
void setLogVersion(QString v = "")
{ m_verlist = QStringList(v); LOG_INFO() << m_verlist;}
void setLogVersion(QStringList v)
@ -52,7 +51,7 @@ public:
void setUnzip(bool i) { m_unzip = i; }
/** Set target filename for copy mode.
* If not set the filename part of the download URL is used. */
void setTarget(QString t) { m_target = t; }
void setTarget(QString& t) { m_target = t; }
void setCache(bool c) { m_usecache = c; }
public slots:

View file

@ -54,7 +54,7 @@ public:
TTSFakeEspeak(QObject *parent): TTSBase(parent) {}
virtual bool start(QString *errStr) { (void)errStr; return true; }
virtual bool stop() { return true; }
virtual TTSStatus voice(QString text, QString wavfile, QString *errStr)
virtual TTSStatus voice(const QString& text, const QString& wavfile, QString *errStr)
{ (void)text; (void)wavfile; (void)errStr; return NoError; }
virtual QString voiceVendor() { return QString("DummyVendor"); }
virtual bool configOk() { return true; }
@ -67,7 +67,7 @@ TTSBase::TTSBase(QObject* parent) : EncTtsSettingInterface(parent)
{
}
TTSStatus TTSBase::voice(QString /*text*/, QString /*wavfile*/, QString* /*errStr*/)
TTSStatus TTSBase::voice(const QString& /*text*/, const QString& /*wavfile*/, QString* /*errStr*/)
{
return NoError;
}