Skip to content

Commit

Permalink
Use assign for deserialize instead of temporary std::string
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Hyyppä <[email protected]>
  • Loading branch information
SamuelSandvik committed Oct 10, 2024
1 parent 2f90c7b commit 814913c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/fastcdr/Cdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ class Cdr
{
uint32_t length = 0;
const char* str = read_string(length);
value = std::string(str, length);
value.assign(str, length);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fastcdr/FastCdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ class Cdr_DllAPI FastCdr
{
uint32_t length = 0;
const char* str = read_string(length);
string_t = std::string(str, length);
string_t.assign(str, length);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/Cdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ Cdr& Cdr::deserialize(
const char* Cdr::read_string(
uint32_t& length)
{
const char* ret_value = "";
const char* ret_value = nullptr;
state state_before_error(*this);

*this >> length;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/FastCdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ FastCdr& FastCdr::deserialize(
const char* FastCdr::read_string(
uint32_t& length)
{
const char* ret_value = "";
const char* ret_value = nullptr;
state state_before_error(*this);

*this >> length;
Expand Down

0 comments on commit 814913c

Please sign in to comment.