From adf3954de202793c3094824f650c086c02c0bbfa Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@bred.dog>
Date: Tue, 3 Sep 2019 23:11:45 -0400
Subject: [PATCH] Replace strange U64 to F64 cast with static_cast...it
 generates more efficient code and the result is the same.

---
 indra/llcommon/CMakeLists.txt                |  2 --
 indra/llcommon/llframetimer.cpp              | 12 +++----
 indra/llcommon/lltimer.cpp                   |  4 +--
 indra/llcommon/u64.cpp                       | 38 --------------------
 indra/llcommon/u64.h                         | 35 ------------------
 indra/llinventory/llparcel.cpp               |  1 -
 indra/llmessage/llnamevalue.cpp              |  1 -
 indra/llmessage/llpacketring.cpp             |  1 -
 indra/llmessage/llsdmessagebuilder.cpp       |  1 -
 indra/llmessage/lltemplatemessagebuilder.cpp |  1 -
 indra/llmessage/lltemplatemessagereader.cpp  |  1 -
 indra/llmessage/llxfer.cpp                   |  1 -
 indra/llmessage/llxfermanager.cpp            |  1 -
 indra/llmessage/message.cpp                  |  1 -
 indra/llplugin/llpluginmessage.cpp           |  1 -
 indra/newview/llviewerobjectlist.cpp         |  1 -
 indra/newview/llviewerprecompiledheaders.h   |  1 -
 17 files changed, 6 insertions(+), 97 deletions(-)
 delete mode 100644 indra/llcommon/u64.cpp
 delete mode 100644 indra/llcommon/u64.h

diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index 9899f87fb2..bb837ba5e9 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -130,7 +130,6 @@ set(llcommon_SOURCE_FILES
     lluuid.cpp
     llworkerthread.cpp
     timing.cpp
-    u64.cpp
     StackWalker.cpp
     )
     
@@ -261,7 +260,6 @@ set(llcommon_HEADER_FILES
     stdtypes.h
     stringize.h
     timer.h
-    u64.h
     StackWalker.h
     )
 
diff --git a/indra/llcommon/llframetimer.cpp b/indra/llcommon/llframetimer.cpp
index a0950588e7..1ecc1b24c6 100644
--- a/indra/llcommon/llframetimer.cpp
+++ b/indra/llcommon/llframetimer.cpp
@@ -25,8 +25,6 @@
 
 #include "linden_common.h"
 
-#include "u64.h"
-
 #include "llframetimer.h"
 
 // Static members
@@ -45,8 +43,8 @@ void LLFrameTimer::updateFrameTime()
 	U64 total_time = totalTime();
 	sFrameDeltaTime = total_time - sTotalTime;
 	sTotalTime = total_time;
-	sTotalSeconds = U64_to_F64(sTotalTime) * USEC_TO_SEC_F64;
-	sFrameTime = U64_to_F64(sTotalTime - sStartTotalTime) * USEC_TO_SEC_F64;
+	sTotalSeconds = static_cast<F64>(sTotalTime) * USEC_TO_SEC_F64;
+	sFrameTime = static_cast<F64>(sTotalTime - sStartTotalTime) * USEC_TO_SEC_F64;
 } 
 
 void LLFrameTimer::start()
@@ -107,7 +105,7 @@ void LLFrameTimer::setExpiryAt(F64 seconds_since_epoch)
 
 F64 LLFrameTimer::expiresAt() const
 {
-	F64 expires_at = U64_to_F64(sStartTotalTime) * USEC_TO_SEC_F64;
+	F64 expires_at = static_cast<F64>(sStartTotalTime) * USEC_TO_SEC_F64;
 	expires_at += mExpiry;
 	return expires_at;
 }
@@ -131,7 +129,7 @@ BOOL LLFrameTimer::checkExpirationAndReset(F32 expiration)
 // static
 F32 LLFrameTimer::getFrameDeltaTimeF32()
 {
-	return (F32)(U64_to_F64(sFrameDeltaTime) * USEC_TO_SEC_F64); 
+	return (F32)(static_cast<F64>(sFrameDeltaTime) * USEC_TO_SEC_F64);
 }
 
 
@@ -140,7 +138,7 @@ F32 LLFrameTimer::getFrameDeltaTimeF32()
 F32  LLFrameTimer::getCurrentFrameTime()
 {
 	U64 frame_time = totalTime() - sTotalTime;
-	return (F32)(U64_to_F64(frame_time) * USEC_TO_SEC_F64); 
+	return (F32)(static_cast<F64>(frame_time) * USEC_TO_SEC_F64);
 }
 
 // Glue code to avoid full class .h file #includes
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index 70ddb1b73a..2103d0a43e 100644
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -28,8 +28,6 @@
 
 #include "lltimer.h"
 
-#include "u64.h"
-
 #if LL_WINDOWS
 #	include "llwin32headerslean.h"
 #elif LL_LINUX || LL_DARWIN
@@ -311,7 +309,7 @@ U64MicrosecondsImplicit LLTimer::getTotalTime()
 // static
 F64SecondsImplicit LLTimer::getTotalSeconds()
 {
-	return F64Microseconds(U64_to_F64(getTotalTime()));
+	return F64Microseconds(static_cast<F64>(getTotalTime()));
 }
 
 void LLTimer::reset()
diff --git a/indra/llcommon/u64.cpp b/indra/llcommon/u64.cpp
deleted file mode 100644
index 5b2e35d5fb..0000000000
--- a/indra/llcommon/u64.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/** 
- * @file u64.cpp
- * @brief Utilities to deal with U64s.
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "u64.h"
-
-F64 U64_to_F64(const U64 value)
-{
-	S64 top_bits = (S64)(value >> 1);
-	F64 result = (F64)top_bits;
-	result *= 2.f;
-	result += (U32)(value & 0x01);
-	return result;
-}
diff --git a/indra/llcommon/u64.h b/indra/llcommon/u64.h
deleted file mode 100644
index a2bc79c45f..0000000000
--- a/indra/llcommon/u64.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/** 
- * @file u64.h
- * @brief Utilities to deal with U64s.
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_U64_H
-#define LL_U64_H
-
- /**
- * @brief Convert a U64 to the closest F64 value.
- */
-LL_COMMON_API F64 U64_to_F64(const U64 value);
-
-#endif
diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp
index de601dc100..5fd348cf08 100644
--- a/indra/llinventory/llparcel.cpp
+++ b/indra/llinventory/llparcel.cpp
@@ -40,7 +40,6 @@
 #include "lltransactionflags.h"
 #include "llsdutil_math.h"
 #include "message.h"
-#include "u64.h"
 #include "llregionflags.h"
 #include <boost/range/adaptor/map.hpp>
 
diff --git a/indra/llmessage/llnamevalue.cpp b/indra/llmessage/llnamevalue.cpp
index d936907c8e..b675354765 100644
--- a/indra/llmessage/llnamevalue.cpp
+++ b/indra/llmessage/llnamevalue.cpp
@@ -31,7 +31,6 @@
 
 #include "llnamevalue.h"
 
-#include "u64.h"
 #include "llstring.h"
 #include "llstringtable.h"
 
diff --git a/indra/llmessage/llpacketring.cpp b/indra/llmessage/llpacketring.cpp
index d4d38e4b7a..bb1820dd0e 100644
--- a/indra/llmessage/llpacketring.cpp
+++ b/indra/llmessage/llpacketring.cpp
@@ -41,7 +41,6 @@
 #include "llproxy.h"
 #include "llrand.h"
 #include "message.h"
-#include "u64.h"
 
 #include "llmessagelog.h"
 
diff --git a/indra/llmessage/llsdmessagebuilder.cpp b/indra/llmessage/llsdmessagebuilder.cpp
index 9360e7a215..823ee655ee 100644
--- a/indra/llmessage/llsdmessagebuilder.cpp
+++ b/indra/llmessage/llsdmessagebuilder.cpp
@@ -34,7 +34,6 @@
 #include "llsdutil.h"
 #include "llsdutil_math.h"
 #include "llsdserialize.h"
-#include "u64.h"
 #include "v3dmath.h"
 #include "v3math.h"
 #include "v4math.h"
diff --git a/indra/llmessage/lltemplatemessagebuilder.cpp b/indra/llmessage/lltemplatemessagebuilder.cpp
index b1db99d1f6..aa8a0d3930 100644
--- a/indra/llmessage/lltemplatemessagebuilder.cpp
+++ b/indra/llmessage/lltemplatemessagebuilder.cpp
@@ -31,7 +31,6 @@
 #include "llmessagetemplate.h"
 #include "llmath.h"
 #include "llquaternion.h"
-#include "u64.h"
 #include "v3dmath.h"
 #include "v3math.h"
 #include "v4math.h"
diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp
index bea497f526..67cc259ca3 100644
--- a/indra/llmessage/lltemplatemessagereader.cpp
+++ b/indra/llmessage/lltemplatemessagereader.cpp
@@ -33,7 +33,6 @@
 #include "llmath.h"
 #include "llquaternion.h"
 #include "message.h"
-#include "u64.h"
 #include "v3dmath.h"
 #include "v3math.h"
 #include "v4math.h"
diff --git a/indra/llmessage/llxfer.cpp b/indra/llmessage/llxfer.cpp
index cd1f629a1a..a515ae8556 100644
--- a/indra/llmessage/llxfer.cpp
+++ b/indra/llmessage/llxfer.cpp
@@ -30,7 +30,6 @@
 #include "lluuid.h"
 #include "llerror.h"
 #include "llmath.h"
-#include "u64.h"
 
 //number of bytes sent in each message
 const U32 LL_XFER_CHUNK_SIZE = 1000;
diff --git a/indra/llmessage/llxfermanager.cpp b/indra/llmessage/llxfermanager.cpp
index e11abd1d91..d98fb4a9fc 100644
--- a/indra/llmessage/llxfermanager.cpp
+++ b/indra/llmessage/llxfermanager.cpp
@@ -35,7 +35,6 @@
 
 #include "llerror.h"
 #include "lluuid.h"
-#include "u64.h"
 
 const F32 LL_XFER_REGISTRATION_TIMEOUT = 60.0f;  // timeout if a registered transfer hasn't been requested in 60 seconds
 const F32 LL_PACKET_TIMEOUT = 3.0f;             // packet timeout at 3 s
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index ed93c0ebb1..116b924f8e 100644
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -67,7 +67,6 @@
 #include "lluuid.h"
 #include "llxfermanager.h"
 #include "llquaternion.h"
-#include "u64.h"
 #include "v3dmath.h"
 #include "v3math.h"
 #include "v4math.h"
diff --git a/indra/llplugin/llpluginmessage.cpp b/indra/llplugin/llpluginmessage.cpp
index 8514ce6ae5..b590f72fad 100644
--- a/indra/llplugin/llpluginmessage.cpp
+++ b/indra/llplugin/llpluginmessage.cpp
@@ -30,7 +30,6 @@
 
 #include "llpluginmessage.h"
 #include "llsdserialize.h"
-#include "u64.h"
 
 /**
  * Constructor.
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 8b09b7320b..67edc53ae6 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -65,7 +65,6 @@
 #include "lltoolmgr.h"
 #include "lltoolpie.h"
 #include "llkeyboard.h"
-#include "u64.h"
 #include "llviewertexturelist.h"
 #include "lldatapacker.h"
 #include "llcallstack.h"
diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h
index c28d1f3053..924dbd647f 100644
--- a/indra/newview/llviewerprecompiledheaders.h
+++ b/indra/newview/llviewerprecompiledheaders.h
@@ -64,7 +64,6 @@
 #include "llsys.h"
 #include "lltimer.h"
 #include "stdtypes.h"
-#include "u64.h"
 
 // Library includes from llmath project
 #include "llmath.h"
-- 
GitLab