Skip to content

Commit

Permalink
Use assign for deserialize instead of temporary std::string (#241)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Hyyppä <samuel.hyyppa@sandvik.com>
Co-authored-by: Samuel Hyyppä <samuel.hyyppa@sandvik.com>
(cherry picked from commit 5b8025b)

# Conflicts:
#	include/fastcdr/Cdr.h
#	include/fastcdr/FastCdr.h
  • Loading branch information
SamuelH91 authored and mergify[bot] committed Dec 17, 2024
1 parent 666dec3 commit c6fbc3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/fastcdr/Cdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,7 @@ class Cdr_DllAPI Cdr
std::string& string_t,
Endianness endianness)
{
<<<<<<< HEAD
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (static_cast<Endianness>(m_endianness) == endianness)) ||
(!m_swapBytes && (static_cast<Endianness>(m_endianness) != endianness));
Expand All @@ -2488,6 +2489,11 @@ class Cdr_DllAPI Cdr
ex.raise();
}

=======
uint32_t length = 0;
const char* str = read_string(length);
value.assign(str, length);
>>>>>>> 5b8025b (Use assign for deserialize instead of temporary std::string (#241))
return *this;
}

Expand Down
5 changes: 5 additions & 0 deletions include/fastcdr/FastCdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1554,8 +1554,13 @@ class Cdr_DllAPI FastCdr
std::string& string_t)
{
uint32_t length = 0;
<<<<<<< HEAD
const char* str = readString(length);
string_t = std::string(str, length);
=======
const char* str = read_string(length);
string_t.assign(str, length);
>>>>>>> 5b8025b (Use assign for deserialize instead of temporary std::string (#241))
return *this;
}

Expand Down

0 comments on commit c6fbc3c

Please sign in to comment.