Skip to content

Commit a97f50c

Browse files
committed
Various (unsuccessful) attempts to reduce object file size.
1 parent b513b73 commit a97f50c

15 files changed

+2414
-3029
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ node_modules
1111
extern/build-helper.sh
1212
Documentation/Reference
1313
extern/build-linux
14+
extern/build-android

Source/CesiumRuntime/CesiumRuntime.Build.cs

+8
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,13 @@ public CesiumRuntime(ReadOnlyTargetRules Target) : base(Target)
207207
PrivatePCHHeaderFile = "Private/PCH.h";
208208
CppStandard = CppStandardVersion.Cpp17;
209209
bEnableExceptions = true;
210+
211+
// if (Target.Platform == UnrealTargetPlatform.Linux)
212+
// {
213+
// Type type = Target.GetType();
214+
// FieldInfo innerField = type.GetField("Inner", BindingFlags.Instance | BindingFlags.NonPublic);
215+
// TargetRules inner = (TargetRules)innerField.GetValue(Target);
216+
// inner.AdditionalCompilerArguments += " -ftime-trace -v";
217+
// }
210218
}
211219
}

Source/CesiumRuntime/Private/CesiumMetadataConversions.cpp

+283
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,286 @@ CesiumMetadataValueTypeToTrueType(FCesiumMetadataValueType ValueType) {
158158

159159
return ECesiumMetadataTrueType_DEPRECATED::None_DEPRECATED;
160160
}
161+
162+
//bool CesiumMetadataConversions<bool, std::string_view>::convert(
163+
// const std::string_view& from,
164+
// bool defaultValue) noexcept {
165+
// FString f(from.size(), from.data());
166+
//
167+
// if (f.Compare("1", ESearchCase::IgnoreCase) == 0 ||
168+
// f.Compare("true", ESearchCase::IgnoreCase) == 0 ||
169+
// f.Compare("yes", ESearchCase::IgnoreCase) == 0) {
170+
// return true;
171+
// }
172+
//
173+
// if (f.Compare("0", ESearchCase::IgnoreCase) == 0 ||
174+
// f.Compare("false", ESearchCase::IgnoreCase) == 0 ||
175+
// f.Compare("no", ESearchCase::IgnoreCase) == 0) {
176+
// return false;
177+
// }
178+
//
179+
// return defaultValue;
180+
//}
181+
//
182+
//template <typename TTo, typename TFrom>
183+
//TTo CesiumMetadataConversions<
184+
// TTo,
185+
// TFrom,
186+
// std::enable_if_t<
187+
// CesiumGltf::IsMetadataInteger<TTo>::value &&
188+
// CesiumGltf::IsMetadataInteger<TFrom>::value &&
189+
// !std::is_same_v<TTo, TFrom>>>::
190+
// convert(TFrom from, TTo defaultValue) noexcept {
191+
// return CesiumUtility::losslessNarrowOrDefault(from, defaultValue);
192+
//}
193+
//
194+
//template struct CesiumMetadataConversions<int8_t, uint8_t, void>;
195+
//template struct CesiumMetadataConversions<int8_t, int16_t, void>;
196+
//template struct CesiumMetadataConversions<int8_t, uint16_t, void>;
197+
//template struct CesiumMetadataConversions<int8_t, int32_t, void>;
198+
//template struct CesiumMetadataConversions<int8_t, uint32_t, void>;
199+
//template struct CesiumMetadataConversions<int8_t, int64_t, void>;
200+
//template struct CesiumMetadataConversions<int8_t, uint64_t, void>;
201+
//
202+
//template struct CesiumMetadataConversions<uint8_t, int8_t, void>;
203+
//template struct CesiumMetadataConversions<uint8_t, int16_t, void>;
204+
//template struct CesiumMetadataConversions<uint8_t, uint16_t, void>;
205+
//template struct CesiumMetadataConversions<uint8_t, int32_t, void>;
206+
//template struct CesiumMetadataConversions<uint8_t, uint32_t, void>;
207+
//template struct CesiumMetadataConversions<uint8_t, int64_t, void>;
208+
//template struct CesiumMetadataConversions<uint8_t, uint64_t, void>;
209+
//
210+
//template struct CesiumMetadataConversions<int16_t, int8_t, void>;
211+
//template struct CesiumMetadataConversions<int16_t, uint8_t, void>;
212+
//template struct CesiumMetadataConversions<int16_t, uint16_t, void>;
213+
//template struct CesiumMetadataConversions<int16_t, int32_t, void>;
214+
//template struct CesiumMetadataConversions<int16_t, uint32_t, void>;
215+
//template struct CesiumMetadataConversions<int16_t, int64_t, void>;
216+
//template struct CesiumMetadataConversions<int16_t, uint64_t, void>;
217+
//
218+
//template struct CesiumMetadataConversions<uint16_t, int8_t, void>;
219+
//template struct CesiumMetadataConversions<uint16_t, uint8_t, void>;
220+
//template struct CesiumMetadataConversions<uint16_t, int16_t, void>;
221+
//template struct CesiumMetadataConversions<uint16_t, int32_t, void>;
222+
//template struct CesiumMetadataConversions<uint16_t, uint32_t, void>;
223+
//template struct CesiumMetadataConversions<uint16_t, int64_t, void>;
224+
//template struct CesiumMetadataConversions<uint16_t, uint64_t, void>;
225+
//
226+
//template struct CesiumMetadataConversions<int32_t, int8_t, void>;
227+
//template struct CesiumMetadataConversions<int32_t, uint8_t, void>;
228+
//template struct CesiumMetadataConversions<int32_t, int16_t, void>;
229+
//template struct CesiumMetadataConversions<int32_t, uint16_t, void>;
230+
//template struct CesiumMetadataConversions<int32_t, uint32_t, void>;
231+
//template struct CesiumMetadataConversions<int32_t, int64_t, void>;
232+
//template struct CesiumMetadataConversions<int32_t, uint64_t, void>;
233+
//
234+
//template struct CesiumMetadataConversions<uint32_t, int8_t, void>;
235+
//template struct CesiumMetadataConversions<uint32_t, uint8_t, void>;
236+
//template struct CesiumMetadataConversions<uint32_t, int16_t, void>;
237+
//template struct CesiumMetadataConversions<uint32_t, uint16_t, void>;
238+
//template struct CesiumMetadataConversions<uint32_t, int32_t, void>;
239+
//template struct CesiumMetadataConversions<uint32_t, int64_t, void>;
240+
//template struct CesiumMetadataConversions<uint32_t, uint64_t, void>;
241+
//
242+
//template struct CesiumMetadataConversions<int64_t, int8_t, void>;
243+
//template struct CesiumMetadataConversions<int64_t, uint8_t, void>;
244+
//template struct CesiumMetadataConversions<int64_t, int16_t, void>;
245+
//template struct CesiumMetadataConversions<int64_t, uint16_t, void>;
246+
//template struct CesiumMetadataConversions<int64_t, int32_t, void>;
247+
//template struct CesiumMetadataConversions<int64_t, uint32_t, void>;
248+
//template struct CesiumMetadataConversions<int64_t, uint64_t, void>;
249+
//
250+
//template struct CesiumMetadataConversions<uint64_t, int8_t, void>;
251+
//template struct CesiumMetadataConversions<uint64_t, uint8_t, void>;
252+
//template struct CesiumMetadataConversions<uint64_t, int16_t, void>;
253+
//template struct CesiumMetadataConversions<uint64_t, uint16_t, void>;
254+
//template struct CesiumMetadataConversions<uint64_t, int32_t, void>;
255+
//template struct CesiumMetadataConversions<uint64_t, uint32_t, void>;
256+
//template struct CesiumMetadataConversions<uint64_t, int64_t, void>;
257+
//
258+
//template <typename TTo, typename TFrom>
259+
//TTo CesiumMetadataConversions<
260+
// TTo,
261+
// TFrom,
262+
// std::enable_if_t<
263+
// CesiumGltf::IsMetadataInteger<TTo>::value &&
264+
// CesiumGltf::IsMetadataFloating<TFrom>::value>>::
265+
// convert(TFrom from, TTo defaultValue) noexcept {
266+
// if (double(std::numeric_limits<TTo>::max()) < from ||
267+
// double(std::numeric_limits<TTo>::lowest()) > from) {
268+
// // Floating-point number is outside the range of this integer type.
269+
// return defaultValue;
270+
// }
271+
//
272+
// return static_cast<TTo>(from);
273+
//}
274+
//
275+
//template struct CesiumMetadataConversions<int8_t, float, void>;
276+
//template struct CesiumMetadataConversions<uint8_t, float, void>;
277+
//template struct CesiumMetadataConversions<int16_t, float, void>;
278+
//template struct CesiumMetadataConversions<uint16_t, float, void>;
279+
//template struct CesiumMetadataConversions<int32_t, float, void>;
280+
//template struct CesiumMetadataConversions<uint32_t, float, void>;
281+
//template struct CesiumMetadataConversions<int64_t, float, void>;
282+
//template struct CesiumMetadataConversions<uint64_t, float, void>;
283+
//
284+
//template struct CesiumMetadataConversions<int8_t, double, void>;
285+
//template struct CesiumMetadataConversions<uint8_t, double, void>;
286+
//template struct CesiumMetadataConversions<int16_t, double, void>;
287+
//template struct CesiumMetadataConversions<uint16_t, double, void>;
288+
//template struct CesiumMetadataConversions<int32_t, double, void>;
289+
//template struct CesiumMetadataConversions<uint32_t, double, void>;
290+
//template struct CesiumMetadataConversions<int64_t, double, void>;
291+
//template struct CesiumMetadataConversions<uint64_t, double, void>;
292+
//
293+
//template <typename TTo>
294+
//TTo CesiumMetadataConversions<
295+
// TTo,
296+
// std::string_view,
297+
// std::enable_if_t<
298+
// CesiumGltf::IsMetadataInteger<TTo>::value && std::is_signed_v<TTo>>>::
299+
// convert(const std::string_view& from, TTo defaultValue) noexcept {
300+
// // Amazingly, C++ has no* string parsing functions that work with strings
301+
// // that might not be null-terminated. So we have to copy to a std::string
302+
// // (which _is_ guaranteed to be null terminated) before parsing.
303+
// // * except std::from_chars, but compiler/library support for the
304+
// // floating-point version of that method is spotty at best.
305+
// std::string temp(from);
306+
//
307+
// char* pLastUsed;
308+
// int64_t parsedValue = std::strtoll(temp.c_str(), &pLastUsed, 10);
309+
// if (pLastUsed == temp.c_str() + temp.size()) {
310+
// // Successfully parsed the entire string as an integer of this type.
311+
// return CesiumUtility::losslessNarrowOrDefault(parsedValue, defaultValue);
312+
// }
313+
//
314+
// // Failed to parse as an integer. Maybe we can parse as a double and
315+
// // truncate it?
316+
// double parsedDouble = std::strtod(temp.c_str(), &pLastUsed);
317+
// if (pLastUsed == temp.c_str() + temp.size()) {
318+
// // Successfully parsed the entire string as a double.
319+
// // Convert it to an integer if we can.
320+
// double truncated = glm::trunc(parsedDouble);
321+
//
322+
// int64_t asInteger = static_cast<int64_t>(truncated);
323+
// double roundTrip = static_cast<double>(asInteger);
324+
// if (roundTrip == truncated) {
325+
// return CesiumUtility::losslessNarrowOrDefault(asInteger, defaultValue);
326+
// }
327+
// }
328+
//
329+
// return defaultValue;
330+
//}
331+
//
332+
//template struct CesiumMetadataConversions<int8_t, std::string_view, void>;
333+
//template struct CesiumMetadataConversions<int16_t, std::string_view, void>;
334+
//template struct CesiumMetadataConversions<int32_t, std::string_view, void>;
335+
//template struct CesiumMetadataConversions<int64_t, std::string_view, void>;
336+
//
337+
//template <typename TTo>
338+
//TTo CesiumMetadataConversions<
339+
// TTo,
340+
// std::string_view,
341+
// std::enable_if_t<
342+
// CesiumGltf::IsMetadataInteger<TTo>::value && !std::is_signed_v<TTo>>>::
343+
// convert(const std::string_view& from, TTo defaultValue) noexcept {
344+
// // Amazingly, C++ has no* string parsing functions that work with strings
345+
// // that might not be null-terminated. So we have to copy to a std::string
346+
// // (which _is_ guaranteed to be null terminated) before parsing.
347+
// // * except std::from_chars, but compiler/library support for the
348+
// // floating-point version of that method is spotty at best.
349+
// std::string temp(from);
350+
//
351+
// char* pLastUsed;
352+
// uint64_t parsedValue = std::strtoull(temp.c_str(), &pLastUsed, 10);
353+
// if (pLastUsed == temp.c_str() + temp.size()) {
354+
// // Successfully parsed the entire string as an integer of this type.
355+
// return CesiumUtility::losslessNarrowOrDefault(parsedValue, defaultValue);
356+
// }
357+
//
358+
// // Failed to parse as an integer. Maybe we can parse as a double and
359+
// // truncate it?
360+
// double parsedDouble = std::strtod(temp.c_str(), &pLastUsed);
361+
// if (pLastUsed == temp.c_str() + temp.size()) {
362+
// // Successfully parsed the entire string as a double.
363+
// // Convert it to an integer if we can.
364+
// double truncated = glm::trunc(parsedDouble);
365+
//
366+
// uint64_t asInteger = static_cast<uint64_t>(truncated);
367+
// double roundTrip = static_cast<double>(asInteger);
368+
// if (roundTrip == truncated) {
369+
// return CesiumUtility::losslessNarrowOrDefault(asInteger, defaultValue);
370+
// }
371+
// }
372+
//
373+
// return defaultValue;
374+
//}
375+
//
376+
//template struct CesiumMetadataConversions<uint8_t, std::string_view, void>;
377+
//template struct CesiumMetadataConversions<uint16_t, std::string_view, void>;
378+
//template struct CesiumMetadataConversions<uint32_t, std::string_view, void>;
379+
//template struct CesiumMetadataConversions<uint64_t, std::string_view, void>;
380+
//
381+
//float CesiumMetadataConversions<float, std::string_view>::convert(
382+
// const std::string_view& from,
383+
// float defaultValue) noexcept {
384+
// // Amazingly, C++ has no* string parsing functions that work with strings
385+
// // that might not be null-terminated. So we have to copy to a std::string
386+
// // (which _is_ guaranteed to be null terminated) before parsing.
387+
// // * except std::from_chars, but compiler/library support for the
388+
// // floating-point version of that method is spotty at best.
389+
// std::string temp(from);
390+
//
391+
// char* pLastUsed;
392+
// float parsedValue = std::strtof(temp.c_str(), &pLastUsed);
393+
// if (pLastUsed == temp.c_str() + temp.size() && !std::isinf(parsedValue)) {
394+
// // Successfully parsed the entire string as a float.
395+
// return parsedValue;
396+
// }
397+
// return defaultValue;
398+
//}
399+
//
400+
//double CesiumMetadataConversions<double, std::string_view>::convert(
401+
// const std::string_view& from,
402+
// double defaultValue) noexcept {
403+
// // Amazingly, C++ has no* string parsing functions that work with strings
404+
// // that might not be null-terminated. So we have to copy to a std::string
405+
// // (which _is_ guaranteed to be null terminated) before parsing.
406+
// // * except std::from_chars, but compiler/library support for the
407+
// // floating-point version of that method is spotty at best.
408+
// std::string temp(from);
409+
//
410+
// char* pLastUsed;
411+
// double parsedValue = std::strtod(temp.c_str(), &pLastUsed);
412+
// if (pLastUsed == temp.c_str() + temp.size() && !std::isinf(parsedValue)) {
413+
// // Successfully parsed the entire string as a double.
414+
// return parsedValue;
415+
// }
416+
// return defaultValue;
417+
//}
418+
//
419+
//FString CesiumMetadataConversions<FString, bool>::convert(
420+
// bool from,
421+
// const FString& defaultValue) noexcept {
422+
// return from ? "true" : "false";
423+
//}
424+
//
425+
//template <typename TFrom>
426+
//FString CesiumMetadataConversions<
427+
// FString,
428+
// TFrom,
429+
// std::enable_if_t<CesiumGltf::IsMetadataScalar<TFrom>::value>>::
430+
// convert(TFrom from, const FString& defaultValue) noexcept {
431+
// return FString(std::to_string(from).c_str());
432+
//}
433+
//
434+
//template struct CesiumMetadataConversions<FString, int8_t, void>;
435+
//template struct CesiumMetadataConversions<FString, uint8_t, void>;
436+
//template struct CesiumMetadataConversions<FString, int16_t, void>;
437+
//template struct CesiumMetadataConversions<FString, uint16_t, void>;
438+
//template struct CesiumMetadataConversions<FString, int32_t, void>;
439+
//template struct CesiumMetadataConversions<FString, uint32_t, void>;
440+
//template struct CesiumMetadataConversions<FString, int64_t, void>;
441+
//template struct CesiumMetadataConversions<FString, uint64_t, void>;
442+
//template struct CesiumMetadataConversions<FString, float, void>;
443+
//template struct CesiumMetadataConversions<FString, double, void>;

Source/CesiumRuntime/Private/CesiumMetadataValue.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ FString UCesiumMetadataValueBlueprintLibrary::GetString(
134134
FCesiumPropertyArray UCesiumMetadataValueBlueprintLibrary::GetArray(
135135
UPARAM(ref) const FCesiumMetadataValue& Value) {
136136
return mpark::visit(
137-
[](auto value) -> FCesiumPropertyArray {
138-
if constexpr (CesiumGltf::IsMetadataArray<decltype(value)>::value) {
137+
[](const auto& value) -> FCesiumPropertyArray {
138+
if constexpr (CesiumGltf::IsMetadataArray<std::remove_cv_t<
139+
std::remove_reference_t<decltype(value)>>>::value) {
139140
return FCesiumPropertyArray(value);
140141
}
141142
return FCesiumPropertyArray();
@@ -148,15 +149,19 @@ bool UCesiumMetadataValueBlueprintLibrary::IsEmpty(
148149
return mpark::holds_alternative<mpark::monostate>(Value._value);
149150
}
150151

152+
FCesiumMetadataValue::FCesiumMetadataValue() noexcept
153+
: _value(mpark::monostate{}), _valueType() {}
154+
151155
template <typename TTo>
152156
/*static*/ TTo FCesiumMetadataValue::convertTo(
153157
const ValueType& Value,
154158
const TTo& DefaultValue) noexcept {
155159
return mpark::visit(
156-
[DefaultValue](auto value) {
157-
return CesiumMetadataConversions<TTo, decltype(value)>::convert(
158-
value,
159-
DefaultValue);
160+
[&DefaultValue](const auto& value) noexcept {
161+
return CesiumMetadataConversions<
162+
TTo,
163+
std::remove_cv_t<std::remove_reference_t<decltype(value)>>>::
164+
convert(value, DefaultValue);
160165
},
161166
Value);
162167
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2020-2023 CesiumGS, Inc. and Contributors
2+
3+
#include "CesiumMetadataValueType.h"
4+
5+
FCesiumMetadataValueType::FCesiumMetadataValueType() noexcept
6+
: Type(ECesiumMetadataType::Invalid),
7+
ComponentType(ECesiumMetadataComponentType::None),
8+
bIsArray(false) {}
9+
10+
FCesiumMetadataValueType::FCesiumMetadataValueType(
11+
ECesiumMetadataType InType,
12+
ECesiumMetadataComponentType InComponentType,
13+
bool IsArray) noexcept
14+
: Type(InType), ComponentType(InComponentType), bIsArray(IsArray) {}
15+
16+
bool FCesiumMetadataValueType::operator==(
17+
const FCesiumMetadataValueType& ValueType) const noexcept {
18+
return Type == ValueType.Type && ComponentType == ValueType.ComponentType &&
19+
bIsArray == ValueType.bIsArray;
20+
}
21+
22+
bool FCesiumMetadataValueType::operator!=(
23+
const FCesiumMetadataValueType& ValueType) const noexcept {
24+
return Type != ValueType.Type || ComponentType != ValueType.ComponentType ||
25+
bIsArray != ValueType.bIsArray;
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2020-2023 CesiumGS, Inc. and Contributors
2+
3+
#include "CesiumPropertyArray.h"
4+
5+
FCesiumPropertyArray::FCesiumPropertyArray() noexcept
6+
: _value(), _elementType() {}
7+
8+
FCesiumPropertyArray::FCesiumPropertyArray(
9+
const FCesiumPropertyArray& rhs) noexcept = default;
10+
11+
FCesiumPropertyArray::FCesiumPropertyArray(
12+
FCesiumPropertyArray&& rhs) noexcept = default;
13+
14+
FCesiumPropertyArray& FCesiumPropertyArray::operator=(
15+
const FCesiumPropertyArray& rhs) noexcept = default;
16+
17+
FCesiumPropertyArray&
18+
FCesiumPropertyArray::operator=(FCesiumPropertyArray&& rhs) noexcept = default;
19+
20+
FCesiumPropertyArray::~FCesiumPropertyArray() noexcept = default;

0 commit comments

Comments
 (0)