diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml
new file mode 100644
index 0000000000..17c0ace02f
--- /dev/null
+++ b/.github/workflows/pre-commit.yaml
@@ -0,0 +1,18 @@
+name: pre-commit
+
+on:
+ pull_request:
+ push:
+ branches: [main, contribute]
+ tags: [v*]
+
+
+jobs:
+ pre-commit:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-python@v4
+ with:
+ python-version: 3.x
+ - uses: pre-commit/action@v3.0.0
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6d296d7a24..fe7dfbac7a 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,9 +1,8 @@
repos:
- - repo: https://bitbucket.org/lindenlab/git-hooks.git
- rev: v1.0.0-beta2
+ - repo: https://github.com/secondlife/git-hooks.git
+ rev: v1.0.0
hooks:
- id: opensource-license
- - id: jira-issue
- id: llsd
- id: no-trigraphs
- id: copyright
@@ -11,7 +10,7 @@ repos:
files: \.(cpp|c|h|py|glsl|cmake|txt)$
exclude: language.txt
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v2.5.0
+ rev: v4.4.0
hooks:
- id: check-xml
- id: mixed-line-ending
diff --git a/autobuild.xml b/autobuild.xml
index 2c42562912..ceb0df7d9f 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -672,9 +672,9 @@
archive
name
darwin64
@@ -684,9 +684,9 @@
archive
name
windows
@@ -696,16 +696,16 @@
archive
name
windows64
version
- 4.0.3.0.576560
+ 4.0.3.0.579696
colladadom
- linux64
-
version
0.132.2
diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt
index 3998e3b196..636b0f0d0d 100644
--- a/indra/cmake/CMakeLists.txt
+++ b/indra/cmake/CMakeLists.txt
@@ -70,99 +70,6 @@ set(cmake_SOURCE_FILES
ZLIBNG.cmake
)
- 00-Common.cmake
- APR.cmake
- Audio.cmake
- Boost.cmake
- bugsplat.cmake
- BuildVersion.cmake
- CEFPlugin.cmake
- CMakeCopyIfDifferent.cmake
- ColladaDom.cmake
- ConfigurePkgConfig.cmake
- CURL.cmake
- Copy3rdPartyLibs.cmake
- GLIB.cmake
- DeploySharedLibs.cmake
- Discord.cmake # Discord rich presence
- DragDrop.cmake
- EXPAT.cmake
- FindAPR.cmake
- FindAutobuild.cmake
- FindFMODSTUDIO.cmake
- FindGLH.cmake
- FindHUNSPELL.cmake
- FindJsonCpp.cmake
- FindNDOF.cmake
- FindOpenJPEG.cmake
- FindSCP.cmake
- FindURIPARSER.cmake
- FindXmlRpcEpi.cmake
- FindZLIBNG.cmake
- FMODSTUDIO.cmake
- FreeType.cmake
- GLEXT.cmake
- GLH.cmake
- GLOD.cmake
-## GStreamer010Plugin.cmake
- GoogleMock.cmake
- Growl.cmake
- Havok.cmake
- Hunspell.cmake
- JPEG.cmake
- JsonCpp.cmake
- LLAddBuildTest.cmake
- LLAppearance.cmake
- LLAudio.cmake
- LLCharacter.cmake
- LLCommon.cmake
- LLCrashLogger.cmake
- LLImage.cmake
- LLImageJ2COJ.cmake
- LLInventory.cmake
- LLKDU.cmake
- LLLogin.cmake
- LLMath.cmake
- LLMeshOptimizer.cmake
- LLMessage.cmake
- LLPhysicsExtensions.cmake
- LLPlugin.cmake
- LLPrimitive.cmake
- LLRender.cmake
- LLSharedLibs.cmake
- LLTestCommand.cmake
- LLUI.cmake
- LLFileSystem.cmake
- LLWindow.cmake
- LLXML.cmake
- Linking.cmake
- MediaPluginBase.cmake
- MESHOPTIMIZER.cmake
- NDOF.cmake
- OPENAL.cmake
- OpenGL.cmake
- OpenJPEG.cmake
- OpenSSL.cmake
- PNG.cmake
- PluginAPI.cmake
- Prebuilt.cmake
- PulseAudio.cmake
- Python.cmake
- TemplateCheck.cmake
- Tracy.cmake
- Tut.cmake
- UI.cmake
- UnixInstall.cmake
- URIPARSER.cmake
- Variables.cmake
- ViewerMiscLibs.cmake
- VisualLeakDetector.cmake
- LibVLCPlugin.cmake
- XmlRpcEpi.cmake
- xxHash.cmake
- ZLIBNG.cmake
- )
-
source_group("Shared Rules" FILES ${cmake_SOURCE_FILES})
set(master_SOURCE_FILES
diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp
index 8f61654de6..2c4a57675e 100644
--- a/indra/llaudio/llaudioengine.cpp
+++ b/indra/llaudio/llaudioengine.cpp
@@ -217,7 +217,8 @@ std::string LLAudioEngine::getInternetStreamURL()
{
if (mStreamingAudioImpl)
return mStreamingAudioImpl->getURL();
- else return std::string();
+
+ return std::string();
}
@@ -358,42 +359,43 @@ void LLAudioEngine::idle()
}
continue;
}
- else
+
+ // Check to see if the current sound is done playing.
+ if (!channelp->isPlaying())
{
- // Check to see if the current sound is done playing, or looped.
- if (!channelp->isPlaying())
+ sourcep->mCurrentDatap = sourcep->mQueuedDatap;
+ sourcep->mQueuedDatap = NULL;
+
+ // Reset the timer so the source doesn't die.
+ sourcep->mAgeTimer.reset();
+
+ // Make sure we have the buffer set up if we just decoded the data
+ if (sourcep->mCurrentDatap)
+ {
+ updateBufferForData(sourcep->mCurrentDatap);
+ }
+
+ // Actually play the associated data.
+ sourcep->setupChannel();
+ channelp->updateBuffer();
+ sourcep->getChannel()->play();
+ continue;
+ }
+
+ // Check to see if the current sound is looped.
+ if (sourcep->isLoop())
+ {
+ // It's a loop, we need to check and see if we're done with it.
+ if (channelp->mLoopedThisFrame)
{
sourcep->mCurrentDatap = sourcep->mQueuedDatap;
sourcep->mQueuedDatap = NULL;
- // Reset the timer so the source doesn't die.
- sourcep->mAgeTimer.reset();
-
- // Make sure we have the buffer set up if we just decoded the data
- if (sourcep->mCurrentDatap)
- {
- updateBufferForData(sourcep->mCurrentDatap);
- }
-
- // Actually play the associated data.
+ // Actually, should do a time sync so if we're a loop master/slave
+ // we don't drift away.
sourcep->setupChannel();
- channelp->updateBuffer();
sourcep->getChannel()->play();
}
- else if (sourcep->isLoop())
- {
- // It's a loop, we need to check and see if we're done with it.
- if (channelp->mLoopedThisFrame)
- {
- sourcep->mCurrentDatap = sourcep->mQueuedDatap;
- sourcep->mQueuedDatap = NULL;
-
- // Actually, should do a time sync so if we're a loop master/slave
- // we don't drift away.
- sourcep->setupChannel();
- sourcep->getChannel()->play();
- }
- }
}
}
@@ -409,18 +411,11 @@ void LLAudioEngine::idle()
for (source_map::value_type& src_pair : mAllSources)
{
LLAudioSource *sourcep = src_pair.second;
- if (sourcep->isMuted())
+ if (sourcep->isMuted() && sourcep->isSyncMaster() && sourcep->getPriority() > max_sm_priority)
{
- continue;
- }
- if (sourcep->isSyncMaster())
- {
- if (sourcep->getPriority() > max_sm_priority)
- {
- sync_masterp = sourcep;
- master_channelp = sync_masterp->getChannel();
- max_sm_priority = sourcep->getPriority();
- }
+ sync_masterp = sourcep;
+ master_channelp = sync_masterp->getChannel();
+ max_sm_priority = sourcep->getPriority();
}
}
@@ -755,7 +750,7 @@ F64 LLAudioEngine::mapWindVecToGain(LLVector3 wind_vec)
}
return (gain);
-}
+}
F64 LLAudioEngine::mapWindVecToPitch(LLVector3 wind_vec)
@@ -996,11 +991,10 @@ void LLAudioEngine::cleanupAudioSource(LLAudioSource *asp)
else
{
LL_DEBUGS("AudioEngine") << "Cleaning up audio sources for "<< asp->getID() <getID() << ")" << LL_ENDL;
- if (sourcep == mCurrentSourcep)
- {
- // Don't reallocate the channel, this will make FMOD goofy.
- //LL_INFOS() << "Calling setSource with same source!" << LL_ENDL;
+ if (sourcep == mCurrentSourcep)
+ {
+ // Don't reallocate the channel, this will make FMOD goofy.
+ //LL_INFOS() << "Calling setSource with same source!" << LL_ENDL;
+ }
+
+ mCurrentSourcep = sourcep;
+
+ updateBuffer();
+ update3DPosition();
}
-
- mCurrentSourcep = sourcep;
-
- updateBuffer();
- update3DPosition();
}
-}
-
bool LLAudioChannel::updateBuffer()
{
diff --git a/indra/llaudio/llaudioengine.h b/indra/llaudio/llaudioengine.h
index 74e264377e..ba3a7f32e3 100644
--- a/indra/llaudio/llaudioengine.h
+++ b/indra/llaudio/llaudioengine.h
@@ -95,6 +95,7 @@ public:
// initialization/startup/shutdown
virtual bool init(void *userdata, const std::string &app_title);
virtual std::string getDriverName(bool verbose) = 0;
+ virtual LLStreamingAudioInterface *createDefaultStreamingAudioImpl() const = 0;
virtual void shutdown();
// Used by the mechanics of the engine
@@ -526,13 +527,13 @@ struct SoundData
const LLUUID& owner_id,
const F32 gain,
const S32 type = LLAudioEngine::AUDIO_TYPE_NONE,
- const LLVector3d &pos_global = LLVector3d::zero)
+ const LLVector3d &pos_global = LLVector3d::zero) :
+ audio_uuid(audio_uuid),
+ owner_id(owner_id),
+ gain(gain),
+ type(type),
+ pos_global(pos_global)
{
- this->audio_uuid = audio_uuid;
- this->owner_id = owner_id;
- this->gain = gain;
- this->type = type;
- this->pos_global = pos_global;
}
};
diff --git a/indra/llaudio/llaudioengine_fmodstudio.cpp b/indra/llaudio/llaudioengine_fmodstudio.cpp
index 9b215337e9..838b91c66f 100644
--- a/indra/llaudio/llaudioengine_fmodstudio.cpp
+++ b/indra/llaudio/llaudioengine_fmodstudio.cpp
@@ -308,10 +308,6 @@ bool LLAudioEngine_FMODSTUDIO::init(void* userdata, const std::string &app_title
Check_FMOD_Error(mSystem->createChannelGroup("Ambient", &mChannelGroups[AUDIO_TYPE_AMBIENT]), "FMOD::System::createChannelGroup");
}
- // set up our favourite FMOD-native streaming audio implementation if none has already been added
- if (!getStreamingAudioImpl()) // no existing implementation added
- setStreamingAudioImpl(new LLStreamingAudio_FMODSTUDIO(mSystem));
-
LL_INFOS("AppInit") << "LLAudioEngine_FMODSTUDIO::init() FMOD Studio initialized correctly" << LL_ENDL;
FMOD_ADVANCEDSETTINGS settings_dump = { };
@@ -395,6 +391,13 @@ std::string LLAudioEngine_FMODSTUDIO::getDriverName(bool verbose)
}
+// create our favourite FMOD-native streaming audio implementation
+LLStreamingAudioInterface *LLAudioEngine_FMODSTUDIO::createDefaultStreamingAudioImpl() const
+{
+ return new LLStreamingAudio_FMODSTUDIO(mSystem);
+}
+
+
void LLAudioEngine_FMODSTUDIO::allocateListener(void)
{
try
diff --git a/indra/llaudio/llaudioengine_fmodstudio.h b/indra/llaudio/llaudioengine_fmodstudio.h
index 0c9b4d186f..e8cc03083b 100644
--- a/indra/llaudio/llaudioengine_fmodstudio.h
+++ b/indra/llaudio/llaudioengine_fmodstudio.h
@@ -59,6 +59,7 @@ public:
// initialization/startup/shutdown
virtual bool init(void *user_data, const std::string &app_title);
virtual std::string getDriverName(bool verbose);
+ virtual LLStreamingAudioInterface* createDefaultStreamingAudioImpl() const;
virtual void allocateListener();
virtual void shutdown();
diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h
index 5c46f6a796..4e25001fff 100644
--- a/indra/llcommon/lldefs.h
+++ b/indra/llcommon/lldefs.h
@@ -167,48 +167,34 @@ const U32 MAXADDRSTR = 17; // 123.567.901.345 = 15 chars + \0 + 1 for good luc
//
// defined for U16, U32, U64, S16, S32, S64, :
// llclampb(a) // clamps a to [0 .. 255]
-//
+//
-template
-inline auto llmax(T1 d1, T2 d2)
+// recursion tail
+template
+inline auto llmax(T data)
{
- return (d1 > d2) ? d1 : d2;
+ return data;
}
-template
-inline auto llmax(T1 d1, T2 d2, T3 d3)
+template
+inline auto llmax(T0 d0, T1 d1, Ts... rest)
{
- auto r = llmax(d1,d2);
- return llmax(r, d3);
+ auto maxrest = llmax(d1, rest...);
+ return (d0 > maxrest)? d0 : maxrest;
}
-template
-inline auto llmax(T1 d1, T2 d2, T3 d3, T4 d4)
+// recursion tail
+template
+inline auto llmin(T data)
{
- auto r1 = llmax(d1,d2);
- auto r2 = llmax(d3,d4);
- return llmax(r1, r2);
+ return data;
}
-template
-inline auto llmin(T1 d1, T2 d2)
+template
+inline auto llmin(T0 d0, T1 d1, Ts... rest)
{
- return (d1 < d2) ? d1 : d2;
-}
-
-template
-inline auto llmin(T1 d1, T2 d2, T3 d3)
-{
- auto r = llmin(d1,d2);
- return (r < d3 ? r : d3);
-}
-
-template
-inline auto llmin(T1 d1, T2 d2, T3 d3, T4 d4)
-{
- auto r1 = llmin(d1,d2);
- auto r2 = llmin(d3,d4);
- return llmin(r1, r2);
+ auto minrest = llmin(d1, rest...);
+ return (d0 < minrest) ? d0 : minrest;
}
template
diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp
index 9b2a2bab60..0abe817f1d 100644
--- a/indra/llcommon/llmd5.cpp
+++ b/indra/llcommon/llmd5.cpp
@@ -96,7 +96,7 @@ LLMD5::LLMD5()
// operation, processing another message block, and updating the
// context.
-void LLMD5::update (const uint1 *input, const size_t input_length) {
+void LLMD5::update (const uint8_t *input, const size_t input_length) {
size_t input_index, buffer_index;
size_t buffer_space; // how much space is left in buffer
@@ -189,7 +189,7 @@ void LLMD5::finalize (){
unsigned char bits[8]; /* Flawfinder: ignore */
size_t index, padLen;
- static uint1 PADDING[64]={
+ static uint8_t PADDING[64]={
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -201,8 +201,8 @@ void LLMD5::finalize (){
}
// Save number of bits.
- // Treat count, a uint64_t, as uint4[2].
- encode (bits, reinterpret_cast(&count), 8);
+ // Treat count, a uint64_t, as uint32_t[2].
+ encode (bits, reinterpret_cast(&count), 8);
// Pad out to 56 mod 64.
index = size_t((count >> 3) & 0x3f);
@@ -412,7 +412,7 @@ Rotation is separate from addition to prevent recomputation.
// LLMD5 basic transformation. Transforms state based on block.
void LLMD5::transform (const U8 block[64]){
- uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+ uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
decode (x, block, 64);
@@ -496,38 +496,38 @@ void LLMD5::transform (const U8 block[64]){
state[3] += d;
// Zeroize sensitive information.
- memset ( (uint1 *) x, 0, sizeof(x));
+ memset ( (uint8_t *) x, 0, sizeof(x));
}
-// Encodes input (UINT4) into output (unsigned char). Assumes len is
+// Encodes input (uint32_t) into output (unsigned char). Assumes len is
// a multiple of 4.
-void LLMD5::encode (uint1 *output, const uint4 *input, const size_t len) {
+void LLMD5::encode (uint8_t *output, const uint32_t *input, const size_t len) {
size_t i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (uint1) (input[i] & 0xff);
- output[j+1] = (uint1) ((input[i] >> 8) & 0xff);
- output[j+2] = (uint1) ((input[i] >> 16) & 0xff);
- output[j+3] = (uint1) ((input[i] >> 24) & 0xff);
+ output[j] = (uint8_t) (input[i] & 0xff);
+ output[j+1] = (uint8_t) ((input[i] >> 8) & 0xff);
+ output[j+2] = (uint8_t) ((input[i] >> 16) & 0xff);
+ output[j+3] = (uint8_t) ((input[i] >> 24) & 0xff);
}
}
-// Decodes input (unsigned char) into output (UINT4). Assumes len is
+// Decodes input (unsigned char) into output (uint32_t). Assumes len is
// a multiple of 4.
-void LLMD5::decode (uint4 *output, const uint1 *input, const size_t len){
+void LLMD5::decode (uint32_t *output, const uint8_t *input, const size_t len){
size_t i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
- (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
+ output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
+ (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
}
diff --git a/indra/llcommon/llmd5.h b/indra/llcommon/llmd5.h
index 8530dc0389..7d6373c20c 100644
--- a/indra/llcommon/llmd5.h
+++ b/indra/llcommon/llmd5.h
@@ -67,6 +67,8 @@ documentation and/or software.
*/
+#include // uint32_t et al.
+
// use for the raw digest output
const int MD5RAW_BYTES = 16;
@@ -75,18 +77,13 @@ const int MD5HEX_STR_SIZE = 33; // char hex[MD5HEX_STR_SIZE]; with null
const int MD5HEX_STR_BYTES = 32; // message system fixed size
class LL_COMMON_API LLMD5 {
-// first, some types:
- typedef unsigned int uint4; // assumes integer is 4 words long
- typedef unsigned short int uint2; // assumes short integer is 2 words long
- typedef unsigned char uint1; // assumes char is 1 word long
-
// how many bytes to grab at a time when checking files
static const int BLOCK_LEN;
public:
// methods for controlled operation:
LLMD5 (); // simple initializer
- void update (const uint1 *input, const size_t input_length);
+ void update (const uint8_t *input, const size_t input_length);
void update (std::istream& stream);
void update (FILE *file);
void update (const std::string& str);
@@ -109,19 +106,19 @@ private:
// next, the private data:
- uint4 state[4];
+ uint32_t state[4];
uint64_t count; // number of *bits*, mod 2^64
- uint1 buffer[64]; // input buffer
- uint1 digest[16];
- uint1 finalized;
+ uint8_t buffer[64]; // input buffer
+ uint8_t digest[16];
+ uint8_t finalized;
// last, the private methods, mostly static:
void init (); // called by all constructors
- void transform (const uint1 *buffer); // does the real update work. Note
+ void transform (const uint8_t *buffer); // does the real update work. Note
// that length is implied to be 64.
- static void encode (uint1 *dest, const uint4 *src, const size_t length);
- static void decode (uint4 *dest, const uint1 *src, const size_t length);
+ static void encode (uint8_t *dest, const uint32_t *src, const size_t length);
+ static void decode (uint32_t *dest, const uint8_t *src, const size_t length);
};
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index 533d473640..25bfb4baa7 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -146,7 +146,7 @@ bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, llssize max_bytes)
// byte. We could store one if needed, since even the incremented
// inbuf won't exceed sizeof(hdr_buf)-1, but there's no need.
}
- std::string header{ hdr_buf, std::string::size_type(inbuf) };
+ std::string header{ hdr_buf, static_cast(inbuf) };
if (str.fail())
{
str.clear();
@@ -2242,7 +2242,7 @@ LLUZipHelper::EZipRresult LLUZipHelper::unzip_llsd(LLSD& data, std::istream& is,
LLUZipHelper::EZipRresult LLUZipHelper::unzip_llsd(LLSD& data, const U8* in, S32 size)
{
U8* result = NULL;
- llssize cur_size = 0;
+ U32 cur_size = 0;
z_stream strm;
constexpr U32 CHUNK = 1024 * 512;
@@ -2448,7 +2448,7 @@ U8* unzip_llsdNavMesh( bool& valid, size_t& outsize, std::istream& is, S32 size
return result;
}
-char* strip_deprecated_header(char* in, llssize& cur_size, llssize* header_size)
+char* strip_deprecated_header(char* in, U32& cur_size, U32* header_size)
{
const char* deprecated_header = " LLSD/Binary ?>";
constexpr size_t deprecated_header_size = 17;
diff --git a/indra/llcommon/llsdserialize.h b/indra/llcommon/llsdserialize.h
index 676b7bfd6a..2f12c6d1ff 100644
--- a/indra/llcommon/llsdserialize.h
+++ b/indra/llcommon/llsdserialize.h
@@ -873,5 +873,5 @@ LL_COMMON_API std::string zip_llsd(LLSD& data);
LL_COMMON_API U8* unzip_llsdNavMesh( bool& valid, size_t& outsize,std::istream& is, S32 size);
// returns a pointer to the array or past the array if the deprecated header exists
-LL_COMMON_API char* strip_deprecated_header(char* in, llssize& cur_size, llssize* header_size = nullptr);
+LL_COMMON_API char* strip_deprecated_header(char* in, U32& cur_size, U32* header_size = nullptr);
#endif // LL_LLSDSERIALIZE_H
diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index a8dcc5226a..bb3d667a42 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -577,10 +577,12 @@ S32 Recording::getSampleCount( const StatType& stat )
// PeriodicRecording
///////////////////////////////////////////////////////////////////////
-PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state)
+PeriodicRecording::PeriodicRecording( size_t num_periods, EPlayState state)
: mAutoResize(num_periods == 0),
mCurPeriod(0),
mNumRecordedPeriods(0),
+ // This guarantee that mRecordingPeriods cannot be empty is essential for
+ // code in several methods.
mRecordingPeriods(num_periods ? num_periods : 1)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
@@ -596,18 +598,19 @@ PeriodicRecording::~PeriodicRecording()
void PeriodicRecording::nextPeriod()
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
if (mAutoResize)
{
mRecordingPeriods.push_back(Recording());
}
Recording& old_recording = getCurRecording();
- mCurPeriod = (mCurPeriod + 1) % mRecordingPeriods.size();
+ inci(mCurPeriod);
old_recording.splitTo(getCurRecording());
- mNumRecordedPeriods = mRecordingPeriods.empty()? 0 :
- llmin(mRecordingPeriods.size() - 1, mNumRecordedPeriods + 1);
+ // Since mRecordingPeriods always has at least one entry, we can always
+ // safely subtract 1 from its size().
+ mNumRecordedPeriods = llmin(mRecordingPeriods.size() - 1, mNumRecordedPeriods + 1);
}
void PeriodicRecording::appendRecording(Recording& recording)
@@ -620,31 +623,29 @@ void PeriodicRecording::appendRecording(Recording& recording)
void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other )
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
if (other.mRecordingPeriods.empty()) return;
getCurRecording().update();
other.getCurRecording().update();
-
- const auto other_recording_slots = other.mRecordingPeriods.size();
+
const auto other_num_recordings = other.getNumRecordedPeriods();
const auto other_current_recording_index = other.mCurPeriod;
- const auto other_oldest_recording_index = (other_current_recording_index + other_recording_slots - other_num_recordings) % other_recording_slots;
+ const auto other_oldest_recording_index = other.previ(other_current_recording_index, other_num_recordings);
// append first recording into our current slot
getCurRecording().appendRecording(other.mRecordingPeriods[other_oldest_recording_index]);
// from now on, add new recordings for everything after the first
- auto other_index = (other_oldest_recording_index + 1) % other_recording_slots;
+ auto other_index = other.nexti(other_oldest_recording_index);
if (mAutoResize)
{
// push back recordings for everything in the middle
- auto other_index = (other_oldest_recording_index + 1) % other_recording_slots;
while (other_index != other_current_recording_index)
{
mRecordingPeriods.push_back(other.mRecordingPeriods[other_index]);
- other_index = (other_index + 1) % other_recording_slots;
+ other.inci(other_index);
}
// add final recording, if it wasn't already added as the first
@@ -653,36 +654,25 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other )
mRecordingPeriods.push_back(other.mRecordingPeriods[other_current_recording_index]);
}
- mCurPeriod = mRecordingPeriods.empty()? 0 : mRecordingPeriods.size() - 1;
+ // mRecordingPeriods is never empty()
+ mCurPeriod = mRecordingPeriods.size() - 1;
mNumRecordedPeriods = mCurPeriod;
}
else
{
- S32 num_to_copy = llmin((S32)mRecordingPeriods.size(), (S32)other_num_recordings);
-
- std::vector::iterator src_it = other.mRecordingPeriods.begin() + other_index ;
- std::vector::iterator dest_it = mRecordingPeriods.begin() + mCurPeriod;
-
+ auto num_to_copy = llmin(mRecordingPeriods.size(), other_num_recordings);
// already consumed the first recording from other, so start counting at 1
- for(S32 i = 1; i < num_to_copy; i++)
+ for (size_t n = 1, srci = other_index, dsti = mCurPeriod;
+ n < num_to_copy;
+ ++n, other.inci(srci), inci(dsti))
{
- *dest_it = *src_it;
-
- if (++src_it == other.mRecordingPeriods.end())
- {
- src_it = other.mRecordingPeriods.begin();
- }
-
- if (++dest_it == mRecordingPeriods.end())
- {
- dest_it = mRecordingPeriods.begin();
- }
+ mRecordingPeriods[dsti] = other.mRecordingPeriods[srci];
}
-
+
// want argument to % to be positive, otherwise result could be negative and thus out of bounds
llassert(num_to_copy >= 1);
// advance to last recording period copied, and make that our current period
- mCurPeriod = (mCurPeriod + num_to_copy - 1) % mRecordingPeriods.size();
+ inci(mCurPeriod, num_to_copy - 1);
mNumRecordedPeriods = llmin(mRecordingPeriods.size() - 1, mNumRecordedPeriods + num_to_copy - 1);
}
@@ -694,13 +684,11 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other )
F64Seconds PeriodicRecording::getDuration() const
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
F64Seconds duration;
- auto num_periods = mRecordingPeriods.size();
- for (size_t i = 1; i <= num_periods; i++)
+ for (size_t n = 0; n < mRecordingPeriods.size(); ++n)
{
- auto index = (mCurPeriod + num_periods - i) % num_periods;
- duration += mRecordingPeriods[index].getDuration();
+ duration += mRecordingPeriods[nexti(mCurPeriod, n)].getDuration();
}
return duration;
}
@@ -737,16 +725,14 @@ const Recording& PeriodicRecording::getCurRecording() const
Recording& PeriodicRecording::getPrevRecording( size_t offset )
{
- auto num_periods = mRecordingPeriods.size();
- offset = llclamp(offset, 0, num_periods - 1);
- return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods];
+ // reuse const implementation, but return non-const reference
+ return const_cast(
+ const_cast(this)->getPrevRecording(offset));
}
const Recording& PeriodicRecording::getPrevRecording( size_t offset ) const
{
- auto num_periods = mRecordingPeriods.size();
- offset = llclamp(offset, 0, num_periods - 1);
- return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods];
+ return mRecordingPeriods[previ(mCurPeriod, offset)];
}
void PeriodicRecording::handleStart()
@@ -789,14 +775,14 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other)
getCurRecording().splitTo(other.getCurRecording());
}
-F64 PeriodicRecording::getPeriodMin( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64 PeriodicRecording::getPeriodMin( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
bool has_value = false;
F64 min_val = std::numeric_limits::max();
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.hasValue(stat))
@@ -811,14 +797,14 @@ F64 PeriodicRecording::getPeriodMin( const StatType& stat, siz
: NaN;
}
-F64 PeriodicRecording::getPeriodMax( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64 PeriodicRecording::getPeriodMax( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
bool has_value = false;
F64 max_val = std::numeric_limits::min();
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.hasValue(stat))
@@ -834,7 +820,7 @@ F64 PeriodicRecording::getPeriodMax( const StatType& stat, siz
}
// calculates means using aggregates per period
-F64 PeriodicRecording::getPeriodMean( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64 PeriodicRecording::getPeriodMean( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
@@ -842,7 +828,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType& stat, si
F64 mean = 0;
S32 valid_period_count = 0;
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.hasValue(stat))
@@ -857,7 +843,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType& stat, si
: NaN;
}
-F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
@@ -866,7 +852,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64 PeriodicRecording::getPeriodMin( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
bool has_value = false;
F64 min_val = std::numeric_limits::max();
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.hasValue(stat))
@@ -904,14 +890,14 @@ F64 PeriodicRecording::getPeriodMin( const StatType& stat, si
: NaN;
}
-F64 PeriodicRecording::getPeriodMax(const StatType& stat, size_t num_periods /*= S32_MAX*/)
+F64 PeriodicRecording::getPeriodMax(const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
bool has_value = false;
F64 max_val = std::numeric_limits::min();
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.hasValue(stat))
@@ -927,7 +913,7 @@ F64 PeriodicRecording::getPeriodMax(const StatType& stat, siz
}
-F64 PeriodicRecording::getPeriodMean( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64 PeriodicRecording::getPeriodMean( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
@@ -935,7 +921,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType& stat, s
S32 valid_period_count = 0;
F64 mean = 0;
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.hasValue(stat))
@@ -950,13 +936,13 @@ F64 PeriodicRecording::getPeriodMean( const StatType& stat, s
: NaN;
}
-F64 PeriodicRecording::getPeriodMedian( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64 PeriodicRecording::getPeriodMedian( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
std::vector buf;
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.getDuration() > (F32Seconds)0.f)
@@ -976,7 +962,7 @@ F64 PeriodicRecording::getPeriodMedian( const StatType& stat,
return F64((buf.size() % 2 == 0) ? (buf[buf.size() / 2 - 1] + buf[buf.size() / 2]) / 2 : buf[buf.size() / 2]);
}
-F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
@@ -985,7 +971,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64Kilobytes PeriodicRecording::getPeriodMin( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
F64Kilobytes min_val(std::numeric_limits::max());
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
min_val = llmin(min_val, recording.getMin(stat));
@@ -1022,13 +1008,13 @@ F64Kilobytes PeriodicRecording::getPeriodMin(const MemStatHandle& stat, size_t n
return getPeriodMin(static_cast&>(stat), num_periods);
}
-F64Kilobytes PeriodicRecording::getPeriodMax(const StatType& stat, size_t num_periods /*= S32_MAX*/)
+F64Kilobytes PeriodicRecording::getPeriodMax(const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
F64Kilobytes max_val(0.0);
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
max_val = llmax(max_val, recording.getMax(stat));
@@ -1042,14 +1028,14 @@ F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, size_t n
return getPeriodMax(static_cast&>(stat), num_periods);
}
-F64Kilobytes PeriodicRecording::getPeriodMean( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64Kilobytes PeriodicRecording::getPeriodMean( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
F64Kilobytes mean(0);
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
mean += recording.getMean(stat);
@@ -1063,7 +1049,7 @@ F64Kilobytes PeriodicRecording::getPeriodMean(const MemStatHandle& stat, size_t
return getPeriodMean(static_cast&>(stat), num_periods);
}
-F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, size_t num_periods /*= S32_MAX*/ )
+F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, size_t num_periods /*= std::numeric_limits::max()*/ )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
@@ -1072,7 +1058,7 @@ F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType
class LLStopWatchControlsMixinCommon
{
@@ -330,7 +331,7 @@ namespace LLTrace
: public LLStopWatchControlsMixin
{
public:
- PeriodicRecording(S32 num_periods, EPlayState state = STOPPED);
+ PeriodicRecording(size_t num_periods, EPlayState state = STOPPED);
~PeriodicRecording();
void nextPeriod();
@@ -353,7 +354,7 @@ namespace LLTrace
Recording snapshotCurRecording() const;
template
- auto getSampleCount(const StatType& stat, size_t num_periods = S32_MAX)
+ auto getSampleCount(const StatType& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
@@ -373,14 +374,14 @@ namespace LLTrace
// catch all for stats that have a defined sum
template
- typename T::value_t getPeriodMin(const StatType& stat, size_t num_periods = S32_MAX)
+ typename T::value_t getPeriodMin(const StatType& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
bool has_value = false;
typename T::value_t min_val(std::numeric_limits::max());
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.hasValue(stat))
@@ -396,39 +397,39 @@ namespace LLTrace
}
template
- T getPeriodMin(const CountStatHandle& stat, size_t num_periods = S32_MAX)
+ T getPeriodMin(const CountStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return T(getPeriodMin(static_cast&>(stat), num_periods));
}
- F64 getPeriodMin(const StatType& stat, size_t num_periods = S32_MAX);
+ F64 getPeriodMin(const StatType& stat, size_t num_periods = std::numeric_limits::max());
template
- T getPeriodMin(const SampleStatHandle& stat, size_t num_periods = S32_MAX)
+ T getPeriodMin(const SampleStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return T(getPeriodMin(static_cast&>(stat), num_periods));
}
- F64 getPeriodMin(const StatType& stat, size_t num_periods = S32_MAX);
+ F64 getPeriodMin(const StatType& stat, size_t num_periods = std::numeric_limits::max());
template
- T getPeriodMin(const EventStatHandle& stat, size_t num_periods = S32_MAX)
+ T getPeriodMin(const EventStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return T(getPeriodMin(static_cast&>(stat), num_periods));
}
- F64Kilobytes getPeriodMin(const StatType& stat, size_t num_periods = S32_MAX);
- F64Kilobytes getPeriodMin(const MemStatHandle& stat, size_t num_periods = S32_MAX);
+ F64Kilobytes getPeriodMin(const StatType& stat, size_t num_periods = std::numeric_limits::max());
+ F64Kilobytes getPeriodMin(const MemStatHandle& stat, size_t num_periods = std::numeric_limits::max());
template
- typename RelatedTypes::fractional_t getPeriodMinPerSec(const StatType& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMinPerSec(const StatType& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
typename RelatedTypes::fractional_t min_val(std::numeric_limits::max());
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
min_val = llmin(min_val, recording.getPerSec(stat));
@@ -437,7 +438,7 @@ namespace LLTrace
}
template
- typename RelatedTypes::fractional_t getPeriodMinPerSec(const CountStatHandle& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMinPerSec(const CountStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return typename RelatedTypes::fractional_t(getPeriodMinPerSec(static_cast&>(stat), num_periods));
@@ -449,14 +450,14 @@ namespace LLTrace
// catch all for stats that have a defined sum
template
- typename T::value_t getPeriodMax(const StatType& stat, size_t num_periods = S32_MAX)
+ typename T::value_t getPeriodMax(const StatType& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
bool has_value = false;
typename T::value_t max_val(std::numeric_limits::min());
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.hasValue(stat))
@@ -472,39 +473,39 @@ namespace LLTrace
}
template
- T getPeriodMax(const CountStatHandle& stat, size_t num_periods = S32_MAX)
+ T getPeriodMax(const CountStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return T(getPeriodMax(static_cast&>(stat), num_periods));
}
- F64 getPeriodMax(const StatType& stat, size_t num_periods = S32_MAX);
+ F64 getPeriodMax(const StatType& stat, size_t num_periods = std::numeric_limits::max());
template
- T getPeriodMax(const SampleStatHandle& stat, size_t num_periods = S32_MAX)
+ T getPeriodMax(const SampleStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return T(getPeriodMax(static_cast&>(stat), num_periods));
}
- F64 getPeriodMax(const StatType& stat, size_t num_periods = S32_MAX);
+ F64 getPeriodMax(const StatType& stat, size_t num_periods = std::numeric_limits::max());
template
- T getPeriodMax(const EventStatHandle& stat, size_t num_periods = S32_MAX)
+ T getPeriodMax(const EventStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return T(getPeriodMax(static_cast&>(stat), num_periods));
}
- F64Kilobytes getPeriodMax(const StatType& stat, size_t num_periods = S32_MAX);
- F64Kilobytes getPeriodMax(const MemStatHandle& stat, size_t num_periods = S32_MAX);
+ F64Kilobytes getPeriodMax(const StatType& stat, size_t num_periods = std::numeric_limits::max());
+ F64Kilobytes getPeriodMax(const MemStatHandle& stat, size_t num_periods = std::numeric_limits::max());
template
- typename RelatedTypes::fractional_t getPeriodMaxPerSec(const StatType& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMaxPerSec(const StatType& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
F64 max_val = std::numeric_limits::min();
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
max_val = llmax(max_val, recording.getPerSec(stat));
@@ -513,7 +514,7 @@ namespace LLTrace
}
template
- typename RelatedTypes::fractional_t getPeriodMaxPerSec(const CountStatHandle& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMaxPerSec(const CountStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return typename RelatedTypes::fractional_t(getPeriodMaxPerSec(static_cast&>(stat), num_periods));
@@ -525,14 +526,14 @@ namespace LLTrace
// catch all for stats that have a defined sum
template
- typename RelatedTypes::fractional_t getPeriodMean(const StatType& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMean(const StatType& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
typename RelatedTypes::fractional_t mean(0);
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.getDuration() > (F32Seconds)0.f)
@@ -546,39 +547,39 @@ namespace LLTrace
}
template
- typename RelatedTypes::fractional_t getPeriodMean(const CountStatHandle& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMean(const CountStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods));
}
- F64 getPeriodMean(const StatType& stat, size_t num_periods = S32_MAX);
+ F64 getPeriodMean(const StatType& stat, size_t num_periods = std::numeric_limits::max());
template
- typename RelatedTypes::fractional_t getPeriodMean(const SampleStatHandle& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMean(const SampleStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods));
}
- F64 getPeriodMean(const StatType& stat, size_t num_periods = S32_MAX);
+ F64 getPeriodMean(const StatType& stat, size_t num_periods = std::numeric_limits::max());
template
- typename RelatedTypes::fractional_t getPeriodMean(const EventStatHandle& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMean(const EventStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods));
}
- F64Kilobytes getPeriodMean(const StatType& stat, size_t num_periods = S32_MAX);
- F64Kilobytes getPeriodMean(const MemStatHandle& stat, size_t num_periods = S32_MAX);
+ F64Kilobytes getPeriodMean(const StatType& stat, size_t num_periods = std::numeric_limits::max());
+ F64Kilobytes getPeriodMean(const MemStatHandle& stat, size_t num_periods = std::numeric_limits::max());
template
- typename RelatedTypes::fractional_t getPeriodMeanPerSec(const StatType& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMeanPerSec(const StatType& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
num_periods = llmin(num_periods, getNumRecordedPeriods());
typename RelatedTypes::fractional_t mean = 0;
- for (S32 i = 1; i <= num_periods; i++)
+ for (size_t i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
if (recording.getDuration() > (F32Seconds)0.f)
@@ -593,64 +594,64 @@ namespace LLTrace
}
template
- typename RelatedTypes::fractional_t getPeriodMeanPerSec(const CountStatHandle& stat, size_t num_periods = S32_MAX)
+ typename RelatedTypes::fractional_t getPeriodMeanPerSec(const CountStatHandle& stat, size_t num_periods = std::numeric_limits::max())
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
return typename RelatedTypes::fractional_t(getPeriodMeanPerSec(static_cast&>(stat), num_periods));
}
- F64 getPeriodMedian( const StatType& stat, size_t num_periods = S32_MAX);
+ F64 getPeriodMedian( const StatType& stat, size_t num_periods = std::numeric_limits::max());
- template
- typename RelatedTypes::fractional_t getPeriodMedianPerSec(const StatType& stat, size_t num_periods = S32_MAX)
- {
- LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
- num_periods = llmin(num_periods, getNumRecordedPeriods());
+ template
+ typename RelatedTypes::fractional_t getPeriodMedianPerSec(const StatType& stat, size_t num_periods = std::numeric_limits::max())
+ {
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
+ num_periods = llmin(num_periods, getNumRecordedPeriods());
- std::vector ::fractional_t> buf;
- for (S32 i = 1; i <= num_periods; i++)
- {
- Recording& recording = getPrevRecording(i);
- if (recording.getDuration() > (F32Seconds)0.f)
- {
- buf.push_back(recording.getPerSec(stat));
- }
- }
- std::sort(buf.begin(), buf.end());
+ std::vector ::fractional_t> buf;
+ for (size_t i = 1; i <= num_periods; i++)
+ {
+ Recording& recording = getPrevRecording(i);
+ if (recording.getDuration() > (F32Seconds)0.f)
+ {
+ buf.push_back(recording.getPerSec(stat));
+ }
+ }
+ std::sort(buf.begin(), buf.end());
- return typename RelatedTypes::fractional_t((buf.size() % 2 == 0) ? (buf[buf.size() / 2 - 1] + buf[buf.size() / 2]) / 2 : buf[buf.size() / 2]);
- }
+ return typename RelatedTypes::fractional_t((buf.size() % 2 == 0) ? (buf[buf.size() / 2 - 1] + buf[buf.size() / 2]) / 2 : buf[buf.size() / 2]);
+ }
- template
- typename RelatedTypes::fractional_t getPeriodMedianPerSec(const CountStatHandle& stat, size_t num_periods = S32_MAX)
- {
- LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS;
- return typename RelatedTypes::fractional_t(getPeriodMedianPerSec(static_cast&>(stat), num_periods));
- }
+ template
+ typename RelatedTypes::fractional_t getPeriodMedianPerSec(const CountStatHandle& stat, size_t num_periods = std::numeric_limits