mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Removed unnecessary ::std::string calls.
All the Error and assert calls were using const ::std::string & arguments. When provided with a char*, the compiler was creating a temporary string object to pass in. This was triggering mallocs everywhere, even in the fast paths. Change-Id: Ie0ad1f240334de677618086bddd64113c56aae6e
This commit is contained in:
committed by
Peter Johnson
parent
055ee09825
commit
61760c839a
@@ -25,17 +25,17 @@
|
||||
* The users don't call this, but instead use the wpi_assert macros in
|
||||
* Utility.h.
|
||||
*/
|
||||
bool wpi_assert_impl(bool conditionValue, const std::string &conditionText,
|
||||
const std::string &message, const std::string &fileName,
|
||||
uint32_t lineNumber, const std::string &funcName) {
|
||||
bool wpi_assert_impl(bool conditionValue, const char *conditionText,
|
||||
const char *message, const char *fileName,
|
||||
uint32_t lineNumber, const char *funcName) {
|
||||
if (!conditionValue) {
|
||||
std::stringstream errorStream;
|
||||
|
||||
errorStream << "Assertion \"" << conditionText << "\" ";
|
||||
errorStream << "on line " << lineNumber << " ";
|
||||
errorStream << "of " << basename(fileName.c_str()) << " ";
|
||||
errorStream << "of " << basename(fileName) << " ";
|
||||
|
||||
if (message.size() > 0) {
|
||||
if (message[0] != '\0') {
|
||||
errorStream << "failed: " << message << std::endl;
|
||||
} else {
|
||||
errorStream << "failed." << std::endl;
|
||||
@@ -59,18 +59,20 @@ bool wpi_assert_impl(bool conditionValue, const std::string &conditionText,
|
||||
* wpi_assertEqual_impl
|
||||
* and wpi_assertNotEqual_impl.
|
||||
*/
|
||||
void wpi_assertEqual_common_impl(const std::string &valueA, const std::string &valueB,
|
||||
const std::string &equalityType, const std::string &message,
|
||||
const std::string &fileName, uint32_t lineNumber,
|
||||
const std::string &funcName) {
|
||||
void wpi_assertEqual_common_impl(const char *valueA, const char *valueB,
|
||||
const char *equalityType,
|
||||
const char *message,
|
||||
const char *fileName,
|
||||
uint32_t lineNumber,
|
||||
const char *funcName) {
|
||||
std::stringstream errorStream;
|
||||
|
||||
errorStream << "Assertion \"" << valueA << " " << equalityType << " "
|
||||
<< valueB << "\" ";
|
||||
errorStream << "on line " << lineNumber << " ";
|
||||
errorStream << "of " << basename(fileName.c_str()) << " ";
|
||||
errorStream << "of " << basename(fileName) << " ";
|
||||
|
||||
if (message.size() > 0) {
|
||||
if (message[0] != '\0') {
|
||||
errorStream << "failed: " << message << std::endl;
|
||||
} else {
|
||||
errorStream << "failed." << std::endl;
|
||||
@@ -92,10 +94,10 @@ void wpi_assertEqual_common_impl(const std::string &valueA, const std::string &v
|
||||
* The users don't call this, but instead use the wpi_assertEqual macros in
|
||||
* Utility.h.
|
||||
*/
|
||||
bool wpi_assertEqual_impl(int valueA, int valueB, const std::string &valueAString,
|
||||
const std::string &valueBString, const std::string &message,
|
||||
const std::string &fileName, uint32_t lineNumber,
|
||||
const std::string &funcName) {
|
||||
bool wpi_assertEqual_impl(int valueA, int valueB, const char *valueAString,
|
||||
const char *valueBString, const char *message,
|
||||
const char *fileName, uint32_t lineNumber,
|
||||
const char *funcName) {
|
||||
if (!(valueA == valueB)) {
|
||||
wpi_assertEqual_common_impl(valueAString, valueBString, "==", message,
|
||||
fileName, lineNumber, funcName);
|
||||
@@ -110,10 +112,10 @@ bool wpi_assertEqual_impl(int valueA, int valueB, const std::string &valueAStrin
|
||||
* The users don't call this, but instead use the wpi_assertNotEqual macros in
|
||||
* Utility.h.
|
||||
*/
|
||||
bool wpi_assertNotEqual_impl(int valueA, int valueB, const std::string &valueAString,
|
||||
const std::string &valueBString, const std::string &message,
|
||||
const std::string &fileName, uint32_t lineNumber,
|
||||
const std::string &funcName) {
|
||||
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *valueAString,
|
||||
const char *valueBString, const char *message,
|
||||
const char *fileName, uint32_t lineNumber,
|
||||
const char *funcName) {
|
||||
if (!(valueA != valueB)) {
|
||||
wpi_assertEqual_common_impl(valueAString, valueBString, "!=", message,
|
||||
fileName, lineNumber, funcName);
|
||||
|
||||
Reference in New Issue
Block a user