summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/WorldStorage/FastNBT.cpp8
-rw-r--r--src/WorldStorage/FastNBT.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp
index 5f979120b..ec43d2f12 100644
--- a/src/WorldStorage/FastNBT.cpp
+++ b/src/WorldStorage/FastNBT.cpp
@@ -614,12 +614,12 @@ void cFastNBTWriter::AddDouble(const AString & a_Name, double a_Value)
-void cFastNBTWriter::AddString(const AString & a_Name, const AString & a_Value)
+void cFastNBTWriter::AddString(const AString & a_Name, const std::string_view a_Value)
{
TagCommon(a_Name, TAG_String);
- UInt16 len = htons(static_cast<UInt16>(a_Value.size()));
- m_Result.append(reinterpret_cast<const char *>(&len), 2);
- m_Result.append(a_Value.c_str(), a_Value.size());
+ const UInt16 Length = htons(static_cast<UInt16>(a_Value.size()));
+ m_Result.append(reinterpret_cast<const char *>(&Length), sizeof(Length));
+ m_Result.append(a_Value);
}
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index 2e1246ccf..257115fe1 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -334,7 +334,7 @@ public:
void AddLong (const AString & a_Name, Int64 a_Value);
void AddFloat (const AString & a_Name, float a_Value);
void AddDouble (const AString & a_Name, double a_Value);
- void AddString (const AString & a_Name, const AString & a_Value);
+ void AddString (const AString & a_Name, std::string_view a_Value);
void AddByteArray(const AString & a_Name, const char * a_Value, size_t a_NumElements);
void AddIntArray (const AString & a_Name, const Int32 * a_Value, size_t a_NumElements);