mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +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
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include "llvm/StringRef.h"
|
||||
|
||||
// Forward declarations
|
||||
class ErrorBase;
|
||||
@@ -41,8 +42,8 @@ class Error {
|
||||
const ErrorBase* GetOriginatingObject() const;
|
||||
double GetTimestamp() const;
|
||||
void Clear();
|
||||
void Set(Code code, const std::string& contextMessage,
|
||||
const std::string& filename, const std::string& function,
|
||||
void Set(Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber, const ErrorBase* originatingObject);
|
||||
|
||||
private:
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Error.h"
|
||||
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
#include "llvm/StringRef.h"
|
||||
|
||||
#define wpi_setErrnoErrorWithContext(context) \
|
||||
(this->SetErrnoError((context), __FILE__, __FUNCTION__, __LINE__))
|
||||
@@ -60,34 +61,29 @@ class ErrorBase {
|
||||
|
||||
virtual Error& GetError();
|
||||
virtual const Error& GetError() const;
|
||||
virtual void SetErrnoError(const std::string& contextMessage,
|
||||
const std::string& filename,
|
||||
const std::string& function,
|
||||
virtual void SetErrnoError(llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
virtual void SetImaqError(int success, const std::string& contextMessage,
|
||||
const std::string& filename,
|
||||
const std::string& function,
|
||||
virtual void SetImaqError(int success, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
virtual void SetError(Error::Code code, const std::string& contextMessage,
|
||||
const std::string& filename,
|
||||
const std::string& function, uint32_t lineNumber) const;
|
||||
virtual void SetWPIError(const std::string& errorMessage, Error::Code code,
|
||||
const std::string& contextMessage,
|
||||
const std::string& filename,
|
||||
const std::string& function,
|
||||
virtual void SetError(Error::Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
virtual void SetWPIError(llvm::StringRef errorMessage, Error::Code code,
|
||||
llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
virtual void CloneError(const ErrorBase& rhs) const;
|
||||
virtual void ClearError() const;
|
||||
virtual bool StatusIsFatal() const;
|
||||
static void SetGlobalError(Error::Code code,
|
||||
const std::string& contextMessage,
|
||||
const std::string& filename,
|
||||
const std::string& function, uint32_t lineNumber);
|
||||
static void SetGlobalWPIError(const std::string& errorMessage,
|
||||
const std::string& contextMessage,
|
||||
const std::string& filename,
|
||||
const std::string& function,
|
||||
uint32_t lineNumber);
|
||||
static void SetGlobalError(Error::Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber);
|
||||
static void SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename,
|
||||
llvm::StringRef function, uint32_t lineNumber);
|
||||
static Error& GetGlobalError();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -30,17 +30,17 @@
|
||||
wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
|
||||
__FUNCTION__)
|
||||
|
||||
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_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_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_assert_impl(bool conditionValue, const char *conditionText,
|
||||
const char *message, const char *fileName,
|
||||
uint32_t lineNumber, const char *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);
|
||||
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);
|
||||
|
||||
void wpi_suspendOnAssertEnabled(bool enabled);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user