Debugger: Save a few cycles in watch data

Change-Id: I1fada2767bedb5c9a90bd8f4f2db6b2c881f111e
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2023-01-03 14:09:44 +01:00
parent b00442e946
commit e1ae96647d
4 changed files with 124 additions and 146 deletions

View File

@@ -15,106 +15,88 @@
namespace Debugger::Internal {
bool isPointerType(const QString &type)
bool isPointerType(const QStringView type)
{
return type.endsWith('*') || type.endsWith("* const");
return type.endsWith('*') || type.endsWith(u"* const");
}
bool isIntType(const QString &type)
bool isIntType(const QStringView type)
{
if (type.isEmpty())
return false;
switch (type.at(0).unicode()) {
case 'b':
return type == "bool";
return type == u"bool";
case 'c':
return type.startsWith("char") &&
( type == "char"
|| type == "char8_t"
|| type == "char16_t"
|| type == "char32_t" );
return type.startsWith(u"char") &&
( type == u"char"
|| type == u"char8_t"
|| type == u"char16_t"
|| type == u"char32_t" );
case 'i':
return type.startsWith("int") &&
( type == "int"
|| type == "int8_t"
|| type == "int16_t"
|| type == "int32_t"
|| type == "int64_t");
return type.startsWith(u"int") &&
( type == u"int"
|| type == u"int8_t"
|| type == u"int16_t"
|| type == u"int32_t"
|| type == u"int64_t");
case 'l':
return type == "long"
|| type == "long int"
|| type == "long unsigned int";
return type == u"long"
|| type == u"long int"
|| type == u"long unsigned int";
case 'p':
return type == "ptrdiff_t";
return type == u"ptrdiff_t";
case 'q':
return type == "qint8" || type == "quint8"
|| type == "qint16" || type == "quint16"
|| type == "qint32" || type == "quint32"
|| type == "qint64" || type == "quint64"
|| type == "qlonglong" || type == "qulonglong";
return type == u"qint8" || type == u"quint8"
|| type == u"qint16" || type == u"quint16"
|| type == u"qint32" || type == u"quint32"
|| type == u"qint64" || type == u"quint64"
|| type == u"qlonglong" || type == u"qulonglong";
case 's':
return type == "short"
|| type == "signed"
|| type == "size_t"
|| type == "std::size_t"
|| type == "std::ptrdiff_t"
|| (type.startsWith("signed") &&
( type == "signed char"
|| type == "signed short"
|| type == "signed short int"
|| type == "signed long"
|| type == "signed long int"
|| type == "signed long long"
|| type == "signed long long int"));
return type == u"short"
|| type == u"signed"
|| type == u"size_t"
|| type == u"std::size_t"
|| type == u"std::ptrdiff_t"
|| (type.startsWith(u"signed") &&
( type == u"signed char"
|| type == u"signed short"
|| type == u"signed short int"
|| type == u"signed long"
|| type == u"signed long int"
|| type == u"signed long long"
|| type == u"signed long long int"));
case 'u':
return type == "unsigned"
|| (type.startsWith("unsigned") &&
( type == "unsigned char"
|| type == "unsigned short"
|| type == "unsigned short int"
|| type == "unsigned int"
|| type == "unsigned long"
|| type == "unsigned long int"
|| type == "unsigned long long"
|| type == "unsigned long long int"))
|| (type.startsWith("uint") &&
( type == "uint8_t"
|| type == "uint16_t"
|| type == "uint32_t"
|| type == "uint64_t"));
return type == u"unsigned"
|| (type.startsWith(u"unsigned") &&
( type == u"unsigned char"
|| type == u"unsigned short"
|| type == u"unsigned short int"
|| type == u"unsigned int"
|| type == u"unsigned long"
|| type == u"unsigned long int"
|| type == u"unsigned long long"
|| type == u"unsigned long long int"))
|| (type.startsWith(u"uint") &&
( type == u"uint8_t"
|| type == u"uint16_t"
|| type == u"uint32_t"
|| type == u"uint64_t"));
default:
return false;
}
}
bool isFloatType(const QString &type)
bool isFloatType(const QStringView type)
{
return type == "float" || type == "double" || type == "qreal" || type == "number";
return type == u"float" || type == u"double" || type == u"qreal" || type == u"number";
}
bool isIntOrFloatType(const QString &type)
bool isIntOrFloatType(const QStringView type)
{
return isIntType(type) || isFloatType(type);
}
WatchItem::WatchItem() :
id(WatchItem::InvalidId),
address(0),
origaddr(0),
size(0),
bitpos(0),
bitsize(0),
elided(0),
arrayIndex(-1),
sortGroup(0),
wantsChildren(false),
valueEnabled(true),
valueEditable(true),
autoDerefCount(0),
outdated(false)
{
}
bool WatchItem::isVTablePointer() const
{
// First case: Cdb only. No user type can be named like this, this is safe.