Added macro to throw an exception but not log it. Useful in some high-performance scenarios.

This commit is contained in:
Daviw Williams 2013-05-27 15:09:43 +02:00
parent 0c7002a1ce
commit de8c69456f
5 changed files with 21 additions and 8 deletions

View File

@ -374,8 +374,8 @@ namespace PolyVox
}
default:
{
//Should never happen
POLYVOX_THROW(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
//Should never happen. We don't log because this hurts performance (preventing inlining?).
POLYVOX_THROW_DONT_LOG(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
}
}
}

View File

@ -258,6 +258,12 @@ namespace PolyVox
#define POLYVOX_THROW(type, message) \
PolyVox::logError() << (message); \
throw type((message))
// Some fast functions (getVoxel(), etc) use exceptions for error handling but don't want the overhead of logging.
// This overhead is present even if no exception is thrown, probably because the presence of the logging code prevents
// some inlining. Therefore we provide this macro which doesn't log for such specialised circumstances.
#define POLYVOX_THROW_DONT_LOG(type, message) \
throw type((message))
#else
namespace PolyVox
{
@ -271,6 +277,13 @@ namespace PolyVox
PolyVox::logError() << (message); \
type except = (type)((message)); \
getThrowHandler()((except), __FILE__, __LINE__)
// Some fast functions (getVoxel(), etc) use exceptions for error handling but don't want the overhead of logging.
// This overhead is present even if no exception is thrown, probably because the presence of the logging code prevents
// some inlining. Therefore we provide this macro which doesn't log for such specialised circumstances.
#define POLYVOX_THROW_DONT_LOG(type, message) \
type except = (type)((message)); \
getThrowHandler()((except), __FILE__, __LINE__)
#endif
namespace PolyVox

View File

@ -241,8 +241,8 @@ namespace PolyVox
}
default:
{
//Should never happen
POLYVOX_THROW(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
//Should never happen. We don't log because this hurts performance (preventing inlining?).
POLYVOX_THROW_DONT_LOG(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
}
}
}

View File

@ -199,8 +199,8 @@ namespace PolyVox
}
default:
{
//Should never happen
POLYVOX_THROW(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
//Should never happen. We don't log because this hurts performance (preventing inlining?).
POLYVOX_THROW_DONT_LOG(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
}
}
}

View File

@ -199,8 +199,8 @@ namespace PolyVox
}
default:
{
//Should never happen
POLYVOX_THROW(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
//Should never happen. We don't log because this hurts performance (preventing inlining?).
POLYVOX_THROW_DONT_LOG(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
}
}
}