Added macro to throw an exception but not log it. Useful in some high-performance scenarios.
This commit is contained in:
parent
0c7002a1ce
commit
de8c69456f
@ -374,8 +374,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//Should never happen
|
//Should never happen. We don't log because this hurts performance (preventing inlining?).
|
||||||
POLYVOX_THROW(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
|
POLYVOX_THROW_DONT_LOG(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,12 @@ namespace PolyVox
|
|||||||
#define POLYVOX_THROW(type, message) \
|
#define POLYVOX_THROW(type, message) \
|
||||||
PolyVox::logError() << (message); \
|
PolyVox::logError() << (message); \
|
||||||
throw type((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
|
#else
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
@ -271,6 +277,13 @@ namespace PolyVox
|
|||||||
PolyVox::logError() << (message); \
|
PolyVox::logError() << (message); \
|
||||||
type except = (type)((message)); \
|
type except = (type)((message)); \
|
||||||
getThrowHandler()((except), __FILE__, __LINE__)
|
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
|
#endif
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
|
@ -241,8 +241,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//Should never happen
|
//Should never happen. We don't log because this hurts performance (preventing inlining?).
|
||||||
POLYVOX_THROW(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
|
POLYVOX_THROW_DONT_LOG(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,8 +199,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//Should never happen
|
//Should never happen. We don't log because this hurts performance (preventing inlining?).
|
||||||
POLYVOX_THROW(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
|
POLYVOX_THROW_DONT_LOG(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,8 +199,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//Should never happen
|
//Should never happen. We don't log because this hurts performance (preventing inlining?).
|
||||||
POLYVOX_THROW(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
|
POLYVOX_THROW_DONT_LOG(std::invalid_argument, "Wrap mode parameter has an unrecognised value.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user