diff options
| author | Glenn Smith <glenn@vector35.com> | 2025-02-12 17:06:31 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2025-02-13 13:51:54 -0500 |
| commit | 5365728462076834832090072788972585260876 (patch) | |
| tree | 488624f36cc3c3da2bb2acb14cf76a9e39918619 /view/sharedcache | |
| parent | 1925885513166893508719453618249182735388 (diff) | |
[SharedCache] Use StringRef for performance
Diffstat (limited to 'view/sharedcache')
| -rw-r--r-- | view/sharedcache/api/sharedcache.cpp | 2 | ||||
| -rw-r--r-- | view/sharedcache/api/sharedcacheapi.h | 2 | ||||
| -rw-r--r-- | view/sharedcache/api/sharedcachecore.h | 3 | ||||
| -rw-r--r-- | view/sharedcache/core/SharedCache.cpp | 6 | ||||
| -rw-r--r-- | view/sharedcache/ui/dsctriage.cpp | 4 |
5 files changed, 9 insertions, 8 deletions
diff --git a/view/sharedcache/api/sharedcache.cpp b/view/sharedcache/api/sharedcache.cpp index 472bb024..2b5ba744 100644 --- a/view/sharedcache/api/sharedcache.cpp +++ b/view/sharedcache/api/sharedcache.cpp @@ -165,7 +165,7 @@ namespace SharedCacheAPI { { DSCSymbol sym; sym.address = value[i].address; - sym.name = value[i].name; + sym.name = StringRef(BNDuplicateStringRef(value[i].name)); sym.image = value[i].image; result.push_back(sym); } diff --git a/view/sharedcache/api/sharedcacheapi.h b/view/sharedcache/api/sharedcacheapi.h index 50d2b382..712cc98e 100644 --- a/view/sharedcache/api/sharedcacheapi.h +++ b/view/sharedcache/api/sharedcacheapi.h @@ -126,7 +126,7 @@ namespace SharedCacheAPI { struct DSCSymbol { uint64_t address; - std::string name; + BinaryNinja::StringRef name; std::string image; }; diff --git a/view/sharedcache/api/sharedcachecore.h b/view/sharedcache/api/sharedcachecore.h index 155f39de..c2e1c7bd 100644 --- a/view/sharedcache/api/sharedcachecore.h +++ b/view/sharedcache/api/sharedcachecore.h @@ -66,6 +66,7 @@ extern "C" typedef struct BNBinaryView BNBinaryView; typedef struct BNSharedCache BNSharedCache; + typedef struct BNStringRef BNStringRef; typedef struct BNDSCImageMemoryMapping { char* filePath; @@ -109,7 +110,7 @@ extern "C" typedef struct BNDSCSymbolRep { uint64_t address; - char* name; + BNStringRef* name; char* image; } BNDSCSymbolRep; diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index 79cff43e..834ac988 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -3154,7 +3154,7 @@ extern "C" for (size_t i = 0; i < value.size(); i++) { symbols[i].address = value[i].second->GetAddress(); - symbols[i].name = BNAllocString(value[i].second->GetRawName().c_str()); + symbols[i].name = BNDuplicateStringRef(value[i].second->GetRawNameRef().GetObject()); symbols[i].image = BNAllocString(value[i].first.c_str()); } return symbols; @@ -3167,7 +3167,7 @@ extern "C" { for (size_t i = 0; i < count; i++) { - BNFreeString(symbols[i].name); + BNFreeStringRef(symbols[i].name); BNFreeString(symbols[i].image); } delete symbols; @@ -3468,7 +3468,7 @@ void SharedCache::Store(SerializationContext& context) const context.writer.StartObject(); Serialize(context, "key", pair2.first); Serialize(context, "val1", pair2.second->GetType()); - Serialize(context, "val2", pair2.second->GetRawName()); + Serialize(context, "val2", (std::string_view)pair2.second->GetRawNameRef()); context.writer.EndObject(); } context.writer.EndArray(); diff --git a/view/sharedcache/ui/dsctriage.cpp b/view/sharedcache/ui/dsctriage.cpp index 008a4dd6..01543c70 100644 --- a/view/sharedcache/ui/dsctriage.cpp +++ b/view/sharedcache/ui/dsctriage.cpp @@ -422,7 +422,7 @@ QVariant SymbolTableModel::data(const QModelIndex& index, int role) const { case 0: // Address column return QString("0x%1").arg(symbol.address, 0, 16); // Display address as hexadecimal case 1: // Name column - return QString::fromStdString(symbol.name); + return QString::fromUtf8(symbol.name.c_str(), symbol.name.size()); case 2: // Image column return QString::fromStdString(symbol.image); default: @@ -473,7 +473,7 @@ void SymbolTableModel::setFilter(std::string text) m_symbols.reserve(m_parent->m_symbols.size()); for (const auto& symbol : m_parent->m_symbols) { - if (symbol.name.find(m_filter) != std::string::npos) + if (((std::string_view)symbol.name).find(m_filter) != std::string::npos) { m_symbols.push_back(symbol); } |
