Commit 6042665d authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

GIT_SILENT: minor qstring optimization

parent 802e3f6a
......@@ -114,15 +114,15 @@ ConfigDlg::ConfigDlg(GlobalGUIConfig* c, TraceData* data,
QString n = cs->_name;
if (n.startsWith(objectPrefix)) {
n = n.remove(0, objectPrefix.length()+1);
n.remove(0, objectPrefix.length()+1);
if (oList.indexOf(n) == -1) oList.append(n);
}
else if (n.startsWith(classPrefix)) {
n = n.remove(0, classPrefix.length()+1);
n.remove(0, classPrefix.length()+1);
if (cList.indexOf(n) == -1) cList.append(n);
}
else if (n.startsWith(filePrefix)) {
n = n.remove(0, filePrefix.length()+1);
n.remove(0, filePrefix.length()+1);
if (fList.indexOf(n) == -1) fList.append(n);
}
}
......
......@@ -201,7 +201,7 @@ void TopLevel::saveCurrentState(const QString& postfix)
QString eventType = _eventType ? _eventType->name() : QStringLiteral("?");
QString eventType2 = _eventType2 ? _eventType2->name() : QStringLiteral("?");
ConfigGroup* stateConfig = ConfigStorage::group(QStringLiteral("CurrentState") + postfix);
ConfigGroup* stateConfig = ConfigStorage::group(QLatin1String("CurrentState") + postfix);
stateConfig->setValue(QStringLiteral("EventType"), eventType);
stateConfig->setValue(QStringLiteral("EventType2"), eventType2);
stateConfig->setValue(QStringLiteral("GroupType"), ProfileContext::typeName(_groupType));
......@@ -950,7 +950,7 @@ void TopLevel::load(QString file)
if (file.isEmpty()) return;
bool showError = true;
if (file == QStringLiteral("."))
if (file == QLatin1Char('.'))
showError = false;
if (_data && _data->parts().count()>0) {
......@@ -1061,7 +1061,7 @@ void TopLevel::loadTraceDelayed()
void TopLevel::reload()
{
QString trace;
if (!_data || _data->parts().count()==0)
if (!_data || _data->parts().isEmpty())
trace = QStringLiteral("."); // open first trace found in dir
else
trace = _data->traceName();
......@@ -1836,7 +1836,7 @@ void TopLevel::updateLayoutActions()
void TopLevel::updateStatusBar()
{
if (!_data || _data->parts().count()==0) {
if (!_data || _data->parts().isEmpty()) {
_statusLabel->setText(i18n("No profile data file loaded."));
return;
}
......
......@@ -1056,8 +1056,8 @@ int CachegrindLoader::loadInternal(TraceData* data,
if (line.stripPrefix("ositions:")) {
prepareNewPart();
QString positions(line);
hasLineInfo = positions.contains(QStringLiteral("line"));
hasAddrInfo = positions.contains(QStringLiteral("instr"));
hasLineInfo = positions.contains(QLatin1String("line"));
hasAddrInfo = positions.contains(QLatin1String("instr"));
continue;
}
break;
......
......@@ -234,7 +234,7 @@ void GlobalConfig::readOptions()
dirs = sourceConfig->value(QStringLiteral("Dirs%1").arg(i),
QStringList()).toStringList();
if (n.isEmpty() || (dirs.count()==0)) continue;
if (n.isEmpty() || (dirs.isEmpty())) continue;
_objectSourceDirs.insert(n, dirs);
}
......@@ -326,7 +326,7 @@ QStringList GlobalConfig::sourceDirs(TraceData* data, TraceObject* o)
for(int i=0;i<ol2.count();i++)
l.prepend( ol2[i] );
if (0) qDebug() << "GlobalConfig::sourceDirs: " << l.join(QStringLiteral(":"));
if (0) qDebug() << "GlobalConfig::sourceDirs: " << l.join(QLatin1Char(':'));
return l;
}
......@@ -475,7 +475,7 @@ void GlobalConfig::setGeneralSourceDirs(QStringList dirs)
void GlobalConfig::setObjectSourceDirs(QString obj, QStringList dirs)
{
if (dirs.count() == 0)
if (dirs.isEmpty())
_objectSourceDirs.remove(obj);
else
_objectSourceDirs.insert(obj, dirs);
......
......@@ -2672,7 +2672,7 @@ void TraceFunctionCycle::add(TraceFunction* f)
void TraceFunctionCycle::setup()
{
if (_members.count()==0) return;
if (_members.isEmpty()) return;
foreach(TraceFunction* f, _members) {
......@@ -2836,7 +2836,7 @@ QString TraceFile::directory()
if (!_dir.isEmpty()) return _dir;
int lastIndex = 0, index;
while ( (index=_name.indexOf(QStringLiteral("/"), lastIndex)) >=0)
while ( (index=_name.indexOf(QLatin1Char('/'), lastIndex)) >=0)
lastIndex = index+1;
if (lastIndex==0) return QString();
......@@ -2849,7 +2849,7 @@ QString TraceFile::directory()
QString TraceFile::shortName() const
{
int lastIndex = 0, index;
while ( (index=_name.indexOf(QStringLiteral("/"), lastIndex)) >=0)
while ( (index=_name.indexOf(QLatin1Char('/'), lastIndex)) >=0)
lastIndex = index+1;
return _name.mid(lastIndex);
......@@ -2937,7 +2937,7 @@ QString TraceObject::directory()
if (!_dir.isEmpty()) return _dir;
int lastIndex = 0, index;
while ( (index=_name.indexOf(QStringLiteral("/"), lastIndex)) >=0)
while ( (index=_name.indexOf(QLatin1Char('/'), lastIndex)) >=0)
lastIndex = index+1;
if (lastIndex==0) return QString();
......@@ -2950,7 +2950,7 @@ QString TraceObject::directory()
QString TraceObject::shortName() const
{
int lastIndex = 0, index;
while ( (index=_name.indexOf(QStringLiteral("/"), lastIndex)) >=0)
while ( (index=_name.indexOf(QLatin1Char('/'), lastIndex)) >=0)
lastIndex = index+1;
return _name.mid(lastIndex);
......@@ -3016,7 +3016,7 @@ void TracePart::setProcessID(int pid)
QString TracePart::shortName() const
{
int lastIndex = 0, index;
while ( (index=_name.indexOf(QStringLiteral("/"), lastIndex)) >=0)
while ( (index=_name.indexOf(QLatin1Char('/'), lastIndex)) >=0)
lastIndex = index+1;
return _name.mid(lastIndex);
......@@ -3095,7 +3095,7 @@ TraceData::~TraceData()
QString TraceData::shortTraceName() const
{
int lastIndex = 0, index;
while ( (index=_traceName.indexOf(QStringLiteral("/"), lastIndex)) >=0)
while ( (index=_traceName.indexOf(QLatin1Char('/'), lastIndex)) >=0)
lastIndex = index+1;
return _traceName.mid(lastIndex);
......@@ -3384,7 +3384,7 @@ TraceClass* TraceData::cls(const QString& fnName, QString& shortName)
pIndex = sIndex;
#endif
while ((index=fnName.indexOf(QStringLiteral("::"), lastIndex)) >=0) {
while ((index=fnName.indexOf(QLatin1String("::"), lastIndex)) >=0) {
if (pIndex>=0 && pIndex<index) break;
lastIndex = index+2;
}
......
......@@ -499,9 +499,9 @@ QString GraphOptions::layoutString(Layout l)
GraphOptions::Layout GraphOptions::layout(QString s)
{
if (s == QStringLiteral("Circular"))
if (s == QLatin1String("Circular"))
return Circular;
if (s == QStringLiteral("LeftRight"))
if (s == QLatin1String("LeftRight"))
return LeftRight;
return TopDown;
}
......@@ -2088,7 +2088,7 @@ void CallGraphView::refresh()
connect(_renderProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
this, SLOT(dotExited()));
_renderProcessCmdLine = renderProgram + " " + renderArgs.join(QStringLiteral(" "));
_renderProcessCmdLine = renderProgram + QLatin1Char(' ') + renderArgs.join(QLatin1Char(' '));
qDebug("CallGraphView::refresh: Starting process %p, '%s'",
_renderProcess, qPrintable(_renderProcessCmdLine));
......@@ -3119,17 +3119,17 @@ void CallGraphView::contextMenuEvent(QContextMenuEvent* e)
CallGraphView::ZoomPosition CallGraphView::zoomPos(QString s)
{
if (s == QStringLiteral("TopLeft"))
if (s == QLatin1String("TopLeft"))
return TopLeft;
if (s == QStringLiteral("TopRight"))
if (s == QLatin1String("TopRight"))
return TopRight;
if (s == QStringLiteral("BottomLeft"))
if (s == QLatin1String("BottomLeft"))
return BottomLeft;
if (s == QStringLiteral("BottomRight"))
if (s == QLatin1String("BottomRight"))
return BottomRight;
if (s == QStringLiteral("Automatic"))
if (s == QLatin1String("Automatic"))
return Auto;
if (s == QStringLiteral("Hide"))
if (s == QLatin1String("Hide"))
return Hide;
return DEFAULT_ZOOMPOS;
......
......@@ -604,7 +604,7 @@ void FunctionSelection::refresh()
functionListModel->setMaxCount(GlobalConfig::maxListCount());
if (!_data || _data->parts().count()==0) {
if (!_data || _data->parts().isEmpty()) {
functionListModel->resetModelData(nullptr, nullptr, QString(), nullptr);
selectTopFunction();
return;
......
......@@ -175,7 +175,7 @@ void MultiView::restoreLayout(const QString& prefix, const QString& postfix)
QString active = g->value(QStringLiteral("ActivePanel"), QString()).toString();
setChildCount(panelCount);
setOrientation( o == QStringLiteral("Horizontal") ?
setOrientation( o == QLatin1String("Horizontal") ?
Qt::Horizontal : Qt::Vertical );
if ( panelCount>1 ) {
QList<int> sizes = toIntList(g->value(QStringLiteral("PanelSizes"), QStringList()).toStringList());
......
......@@ -220,7 +220,7 @@ QString BasePartItem::text(int textNo) const
if (!_data)
return QObject::tr("(no trace)");
if (_data->parts().count() == 0)
if (_data->parts().isEmpty())
return QObject::tr("(no part)");
}
return QString();
......
......@@ -385,7 +385,7 @@ static bool searchFileRecursive(QString& dir, const QString& name)
QStringList subdirs = d.entryList();
QStringList::const_iterator it =subdirs.constBegin();
for(; it != subdirs.constEnd(); ++it ) {
if (*it == QLatin1String(".") || *it == QLatin1String("..") || *it == QLatin1String("CVS")) continue;
if (*it == QLatin1Char('.') || *it == QLatin1String("..") || *it == QLatin1String("CVS")) continue;
dir = d.filePath(*it);
if (searchFileRecursive(dir, name)) return true;
......
......@@ -698,7 +698,7 @@ bool RectDrawing::drawField(QPainter* p, int f, DrawParams* dp)
if (name[breakPos-1].category() == QChar::Separator_Space)
name = name.left(breakPos-1);
else
name = name.left(breakPos);
name.truncate(breakPos);
}
else { // bottom
w = pixW + findBreakBackwards(breakPos, name, _fm, unusedWidth - pixW);
......@@ -1130,7 +1130,7 @@ void TreeMapItem::addFreeRect(const QRect& r)
// do not add invalid rects
if ((r.width() < 1) || (r.height() < 1)) return;
if (0) qDebug() << "addFree(" << path(0).join(QStringLiteral("/")) << ", "
if (0) qDebug() << "addFree(" << path(0).join(QLatin1Char('/')) << ", "
<< r.x() << "/" << r.y() << "-"
<< r.width() << "x" << r.height() << ")";
......@@ -1575,7 +1575,7 @@ TreeMapItem* TreeMapWidget::item(int x, int y) const
i = list->at(idx);
if (DEBUG_DRAWING)
qDebug() << " Checking " << i->path(0).join(QStringLiteral("/")) << " ("
qDebug() << " Checking " << i->path(0).join(QLatin1Char('/')) << " ("
<< i->itemRect().x() << "/" << i->itemRect().y()
<< "-" << i->itemRect().width()
<< "x" << i->itemRect().height() << ")";
......@@ -1598,7 +1598,7 @@ TreeMapItem* TreeMapWidget::item(int x, int y) const
if (DEBUG_DRAWING)
qDebug() << "item(" << x << "," << y << "): Got "
<< p->path(0).join(QStringLiteral("/")) << " (Size "
<< p->path(0).join(QLatin1Char('/')) << " (Size "
<< p->itemRect().width() << "x" << p->itemRect().height()
<< ", Val " << p->value() << ")";
}
......@@ -1761,7 +1761,7 @@ void TreeMapWidget::setCurrent(TreeMapItem* i, bool kbd)
// remove mark
_markNo = 0;
if (i) qDebug() << "setCurrent(" << i->path(0).join(QStringLiteral("/"))
if (i) qDebug() << "setCurrent(" << i->path(0).join(QLatin1Char('/'))
<< ") - mark removed";
// always complete redraw needed to remove mark
......@@ -2206,7 +2206,7 @@ void TreeMapWidget::drawTreeMap()
if (_needsRefresh) {
if (DEBUG_DRAWING)
qDebug() << "Redrawing " << _needsRefresh->path(0).join(QStringLiteral("/"));
qDebug() << "Redrawing " << _needsRefresh->path(0).join(QLatin1Char('/'));
if (_needsRefresh == _base) {
// redraw whole widget
......@@ -2325,7 +2325,7 @@ void TreeMapWidget::drawItems(QPainter* p,
TreeMapItem* item)
{
if (DEBUG_DRAWING)
qDebug() << "+drawItems(" << item->path(0).join(QStringLiteral("/")) << ", "
qDebug() << "+drawItems(" << item->path(0).join(QLatin1Char('/')) << ", "
<< item->itemRect().x() << "/" << item->itemRect().y()
<< "-" << item->itemRect().width() << "x"
<< item->itemRect().height() << "), Val " << item->value()
......@@ -2398,7 +2398,7 @@ void TreeMapWidget::drawItems(QPainter* p,
r = d.remainingRect(item);
if (DEBUG_DRAWING)
qDebug() << "-drawItems(" << item->path(0).join(QStringLiteral("/")) << ")";
qDebug() << "-drawItems(" << item->path(0).join(QLatin1Char('/')) << ")";
return;
}
......@@ -2486,7 +2486,7 @@ void TreeMapWidget::drawItems(QPainter* p,
// set selfRect (not occupied by children) for tooltip
item->addFreeRect(sr);
if (0) qDebug() << "Item " << item->path(0).join(QStringLiteral("/")) << ": SelfR "
if (0) qDebug() << "Item " << item->path(0).join(QLatin1Char('/')) << ": SelfR "
<< sr.x() << "/" << sr.y() << "-" << sr.width()
<< "/" << sr.height() << ", self " << self << "/"
<< user_sum;
......@@ -2617,7 +2617,7 @@ void TreeMapWidget::drawItems(QPainter* p,
drawItemArray(p, item, r, user_sum, list, idx, list->count(), goBack);
if (DEBUG_DRAWING)
qDebug() << "-drawItems(" << item->path(0).join(QStringLiteral("/")) << ")";
qDebug() << "-drawItems(" << item->path(0).join(QLatin1Char('/')) << ")";
}
// fills area with a pattern if to small to draw children
......@@ -2647,7 +2647,7 @@ void TreeMapWidget::drawFill(TreeMapItem* i, QPainter* p, const QRect& r,
while (len>0 && (i=list->value(idx))) {
if (DEBUG_DRAWING)
qDebug() << " Reset Rect " << i->path(0).join(QStringLiteral("/"));
qDebug() << " Reset Rect " << i->path(0).join(QLatin1Char('/'));
i->clearItemRect();
if (goBack) --idx; else ++idx;
......@@ -2680,7 +2680,7 @@ bool TreeMapWidget::drawItemArray(QPainter* p, TreeMapItem* item,
}
if (DEBUG_DRAWING)
qDebug() << " +drawItemArray(" << item->path(0).join(QStringLiteral("/"))
qDebug() << " +drawItemArray(" << item->path(0).join(QLatin1Char('/'))
<< ", " << r.x() << "/" << r.y() << "-" << r.width()
<< "x" << r.height() << ")";
......@@ -2727,7 +2727,7 @@ bool TreeMapWidget::drawItemArray(QPainter* p, TreeMapItem* item,
}
if (DEBUG_DRAWING)
qDebug() << " -drawItemArray(" << item->path(0).join(QStringLiteral("/"))
qDebug() << " -drawItemArray(" << item->path(0).join(QLatin1Char('/'))
<< ")";
return drawOn;
......@@ -2742,7 +2742,7 @@ bool TreeMapWidget::drawItemArray(QPainter* p, TreeMapItem* item,
if (user_sum <= 0) {
if (DEBUG_DRAWING)
qDebug() << "drawItemArray: Reset " << i->path(0).join(QStringLiteral("/"));
qDebug() << "drawItemArray: Reset " << i->path(0).join(QLatin1Char('/'));
i->clearItemRect();
if (goBack) --idx; else ++idx;
......@@ -2758,7 +2758,7 @@ bool TreeMapWidget::drawItemArray(QPainter* p, TreeMapItem* item,
drawFill(item, p, fullRect, list, idx, len, goBack);
if (DEBUG_DRAWING)
qDebug() << " -drawItemArray(" << item->path(0).join(QStringLiteral("/"))
qDebug() << " -drawItemArray(" << item->path(0).join(QLatin1Char('/'))
<< "): Stop";
return false;
}
......@@ -2774,7 +2774,7 @@ bool TreeMapWidget::drawItemArray(QPainter* p, TreeMapItem* item,
if ((item->sorting(nullptr) != -1) && (nextPos < _visibleWidth)) {
drawFill(item, p, fullRect, list, idx, len, goBack);
if (DEBUG_DRAWING)
qDebug() << " -drawItemArray(" << item->path(0).join(QStringLiteral("/"))
qDebug() << " -drawItemArray(" << item->path(0).join(QLatin1Char('/'))
<< "): Stop";
return false;
}
......@@ -2832,7 +2832,7 @@ bool TreeMapWidget::drawItemArray(QPainter* p, TreeMapItem* item,
}
if (DEBUG_DRAWING)
qDebug() << " -drawItemArray(" << item->path(0).join(QStringLiteral("/"))
qDebug() << " -drawItemArray(" << item->path(0).join(QLatin1Char('/'))
<< "): Continue";
return true;
......
......@@ -121,7 +121,7 @@ void ConfigDialog::activate(QString s)
QString page = s;
_activeSetting.clear();
int p = s.indexOf(QStringLiteral("/"));
int p = s.indexOf(QLatin1Char('/'));
if (p>0) {
page = s.left(p);
_activeSetting = s.mid(p+1);
......
......@@ -149,7 +149,7 @@ void QCGTopLevel::saveCurrentState(const QString& postfix)
if (_eventType) eventType = _eventType->name();
if (_eventType2) eventType2 = _eventType2->name();
ConfigGroup* stateConfig = ConfigStorage::group(QStringLiteral("CurrentState") + postfix);
ConfigGroup* stateConfig = ConfigStorage::group(QLatin1String("CurrentState") + postfix);
stateConfig->setValue(QStringLiteral("EventType"), eventType);
stateConfig->setValue(QStringLiteral("EventType2"), eventType2);
stateConfig->setValue(QStringLiteral("GroupType"), ProfileContext::typeName(_groupType));
......@@ -242,7 +242,7 @@ void QCGTopLevel::recentFilesMenuAboutToShow()
QStringList()).toStringList();
delete generalConfig;
if (recentFiles.count() == 0)
if (recentFiles.isEmpty())
popup->addAction(tr("(No recent files)"));
else {
foreach(const QString& file, recentFiles) {
......@@ -1662,7 +1662,7 @@ void QCGTopLevel::updateLayoutActions()
void QCGTopLevel::updateStatusBar()
{
if (!_data || _data->parts().count()==0) {
if (!_data || _data->parts().isEmpty()) {
_statusLabel->setText(tr("No profile data file loaded."));
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment