Removed stringstream from assignment from double.

This commit is contained in:
Brad Arant 2024-07-09 08:29:43 -07:00
parent bfe5283492
commit cca957b948
4 changed files with 8 additions and 12 deletions

View File

@ -84,11 +84,9 @@ namespace coreutils {
}
MString::MString(double value) {
std::stringstream temp;
temp << std::format("{}", value);
std::string temp2 = temp.str();
setSize(temp2.length());
memcpy(this->data, (char *)temp2.data(), temp2.length());
std::string temp = std::format("{}", value);
setSize(temp.length());
memcpy(this->data, (char *)temp.data(), temp.length());
cursor = this->data;
}
@ -133,11 +131,9 @@ namespace coreutils {
}
MString &MString::operator=(double value) {
std::stringstream temp;
temp << std::format("{}", value);
std::string temp2 = temp.str();
setSize(temp2.length());
memcpy(this->data, (char *)temp2.data(), temp2.length());
std::string temp = std::format("{}", value);
setSize(temp.length());
memcpy(this->data, (char *)temp.data(), temp.length());
cursor = this->data;
return *this;
}

View File

@ -1,4 +1,4 @@
#!/bin/bash
g++ -g -o zstring_test zstring_test.cpp -I.. -L.. -lCoreUtils
g++ -g -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils
g++ -g -std=c++20 -o zstring_test zstring_test.cpp -I.. -L.. -lCoreUtils
g++ -g -std=c++20 -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils
#g++ -o jstring_test jstring_test.cpp -I.. -L.. -lCoreUtils

Binary file not shown.

Binary file not shown.