Skip to content

Commit 6dd834d

Browse files
authored
Ordered code fixes (#2968)
* Fix endianness detection in OrderedCode (and prevent further regression.) * Use static_assert for constant checks * Add a benchmark for SkipToNextSpecialByte * Move string_apple_benchmark next to string_apple_test * Accept non-const references in benchmark functions This is a port of cl/132348268. * Adjust Xcode project * Add GoogleBenchmark as a dependency
1 parent 00247dd commit 6dd834d

File tree

8 files changed

+132
-22
lines changed

8 files changed

+132
-22
lines changed

Firestore/Example/Benchmarks/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,3 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
if(APPLE)
16-
cc_binary(
17-
firebase_firestore_util_string_apple_benchmark
18-
SOURCES
19-
string_apple_benchmark.mm
20-
DEPENDS
21-
benchmark
22-
benchmark_main
23-
firebase_firestore_util_base_apple
24-
)
25-
endif()

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
358DBA8B2560C65D9EB23C35 /* Pods_Firestore_IntegrationTests_macOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39B832380209CC5BAF93BC52 /* Pods_Firestore_IntegrationTests_macOS.framework */; };
125125
36E174A66C323891AEA16A2A /* FIRTimestampTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B65D34A7203C99090076A5E1 /* FIRTimestampTest.m */; };
126126
36FD4CE79613D18BC783C55B /* string_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0EE5300F8233D14025EF0456 /* string_apple_test.mm */; };
127+
37C4BF11C8B2B8B54B5ED138 /* string_apple_benchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C73C0CC6F62A90D8573F383 /* string_apple_benchmark.mm */; };
127128
37EC6C6EA9169BB99078CA96 /* reference_set_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 132E32997D781B896672D30A /* reference_set_test.cc */; };
128129
38208AC761FF994BA69822BE /* async_queue_std_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB4681208EA0BE00554BA2 /* async_queue_std_test.cc */; };
129130
38430E0E07C54FCD399AE919 /* FIRQueryTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E046202154AA00B64F25 /* FIRQueryTests.mm */; };
@@ -364,6 +365,7 @@
364365
627253FDEC6BB5549FE77F4E /* tree_sorted_map_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA4D20A36DBB00BCEB75 /* tree_sorted_map_test.cc */; };
365366
62DA31B79FE97A90EEF28B0B /* delayed_constructor_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = D0A6E9136804A41CEC9D55D4 /* delayed_constructor_test.cc */; };
366367
63BB61B6366E7F80C348419D /* FSTLevelDBTransactionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 132E36BB104830BD806351AC /* FSTLevelDBTransactionTests.mm */; };
368+
649B9E65663480F45DDBA021 /* ordered_code_benchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 535B1420A19BEAA7FA4D77C8 /* ordered_code_benchmark.mm */; };
367369
660E99DEDA0A6FC1CCB200F9 /* FIRArrayTransformTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73866A9F2082B069009BB4FF /* FIRArrayTransformTests.mm */; };
368370
6672B445E006A7708B8531ED /* FSTImmutableSortedDictionary+Testing.m in Sources */ = {isa = PBXBuildFile; fileRef = DE2EF0801F3D0B6E003D0CDC /* FSTImmutableSortedDictionary+Testing.m */; };
369371
66FAB8EAC012A3822BD4D0C9 /* leveldb_util_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 332485C4DCC6BA0DBB5E31B7 /* leveldb_util_test.cc */; };
@@ -392,6 +394,7 @@
392394
731541612214AFFA0037F4DC /* query_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 731541602214AFFA0037F4DC /* query_spec_test.json */; };
393395
736C4E82689F1CA1859C4A3F /* XCTestCase+Await.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0372021401E00B64F25 /* XCTestCase+Await.mm */; };
394396
73866AA12082B0A5009BB4FF /* FIRArrayTransformTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73866A9F2082B069009BB4FF /* FIRArrayTransformTests.mm */; };
397+
73A76304FED6838CBFE74E0E /* ordered_code_benchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 535B1420A19BEAA7FA4D77C8 /* ordered_code_benchmark.mm */; };
395398
73E42D984FB36173A2BDA57C /* FSTEventAccumulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0392021401F00B64F25 /* FSTEventAccumulator.mm */; };
396399
73F1F73C2210F3D800E1F692 /* memory_index_manager_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73F1F7392210F3D800E1F692 /* memory_index_manager_test.mm */; };
397400
73F1F73D2210F3D800E1F692 /* index_manager_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73F1F73B2210F3D800E1F692 /* index_manager_test.mm */; };
@@ -426,6 +429,7 @@
426429
86E6FC2B7657C35B342E1436 /* sorted_map_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA4E20A36DBB00BCEB75 /* sorted_map_test.cc */; };
427430
8705C4856498F66E471A0997 /* FIRWriteBatchTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E06F202154D600B64F25 /* FIRWriteBatchTests.mm */; };
428431
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
432+
87B5AC3EBF0E83166B142FA4 /* string_apple_benchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C73C0CC6F62A90D8573F383 /* string_apple_benchmark.mm */; };
429433
88FD82A1FC5FEC5D56B481D8 /* maybe_document.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE7E20B89AAC00B5BCE7 /* maybe_document.pb.cc */; };
430434
8943A7C0750CEB0B98D21209 /* FSTPersistenceTestHelpers.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E08D2021552B00B64F25 /* FSTPersistenceTestHelpers.mm */; };
431435
897F3C1936612ACB018CA1DD /* http.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE9720B89AAC00B5BCE7 /* http.pb.cc */; };
@@ -453,6 +457,7 @@
453457
9783FAEA4CF758E8C4C2D76E /* hashing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54511E8D209805F8005BD28F /* hashing_test.cc */; };
454458
9794E074439ABE5457E60F35 /* xcgmock_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4425A513895DEC60325A139E /* xcgmock_test.mm */; };
455459
9A29D572C64CA1FA62F591D4 /* FIRQueryTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E069202154D500B64F25 /* FIRQueryTests.mm */; };
460+
9A5100FFDA685B5F0748EA4E /* ordered_code_benchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 535B1420A19BEAA7FA4D77C8 /* ordered_code_benchmark.mm */; };
456461
9AC28D928902C6767A11F5FC /* objc_type_traits_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2A0CF41BA5AED6049B0BEB2C /* objc_type_traits_apple_test.mm */; };
457462
9AC604BF7A76CABDF26F8C8E /* cc_compilation_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1B342370EAE3AA02393E33EB /* cc_compilation_test.cc */; };
458463
9BD7DC8F5ADA0FE64AFAFA75 /* FSTLRUGarbageCollectorTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CC9650220A0E93200A2D6A1 /* FSTLRUGarbageCollectorTests.mm */; };
@@ -549,6 +554,7 @@
549554
C5C01A1FB216DA4BA8BF1A02 /* stream_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = B66D8995213609EE0086DA0C /* stream_test.mm */; };
550555
C5DEDF6148FD41B3000DDD5C /* FSTMemoryRemoteDocumentCacheTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E08C2021552B00B64F25 /* FSTMemoryRemoteDocumentCacheTests.mm */; };
551556
C5F1E2220E30ED5EAC9ABD9E /* mutation.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE8220B89AAC00B5BCE7 /* mutation.pb.cc */; };
557+
C71AD99EE8D176614E742FD7 /* string_apple_benchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C73C0CC6F62A90D8573F383 /* string_apple_benchmark.mm */; };
552558
C7F174164D7C55E35A526009 /* resource_path_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B686F2B02024FFD70028D6BE /* resource_path_test.cc */; };
553559
C80B10E79CDD7EF7843C321E /* objc_type_traits_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2A0CF41BA5AED6049B0BEB2C /* objc_type_traits_apple_test.mm */; };
554560
C8D3CE2343E53223E6487F2C /* Pods_Firestore_Example_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5918805E993304321A05E82B /* Pods_Firestore_Example_iOS.framework */; };
@@ -758,6 +764,8 @@
758764
403DBF6EFB541DFD01582AA3 /* path_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = path_test.cc; sourceTree = "<group>"; };
759765
4425A513895DEC60325A139E /* xcgmock_test.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = xcgmock_test.mm; sourceTree = "<group>"; };
760766
444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = hard_assert_test.cc; sourceTree = "<group>"; };
767+
4C73C0CC6F62A90D8573F383 /* string_apple_benchmark.mm */ = {isa = PBXFileReference; includeInIndex = 1; path = string_apple_benchmark.mm; sourceTree = "<group>"; };
768+
535B1420A19BEAA7FA4D77C8 /* ordered_code_benchmark.mm */ = {isa = PBXFileReference; includeInIndex = 1; path = ordered_code_benchmark.mm; sourceTree = "<group>"; };
761769
54131E9620ADE678001DF3FF /* string_format_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_format_test.cc; sourceTree = "<group>"; };
762770
544129D021C2DDC800EFB9CC /* query.pb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = query.pb.h; sourceTree = "<group>"; };
763771
544129D121C2DDC800EFB9CC /* common.pb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.pb.h; sourceTree = "<group>"; };
@@ -1265,6 +1273,7 @@
12651273
54A0353420A3D8CB003E0143 /* iterator_adaptors_test.cc */,
12661274
54C2294E1FECABAE007D065B /* log_test.cc */,
12671275
B696858F221770F000271095 /* objc_compatibility_apple_test.mm */,
1276+
535B1420A19BEAA7FA4D77C8 /* ordered_code_benchmark.mm */,
12681277
AB380D03201BC6E400D97691 /* ordered_code_test.cc */,
12691278
403DBF6EFB541DFD01582AA3 /* path_test.cc */,
12701279
54740A531FC913E500713A1A /* secure_random_test.cc */,
@@ -1273,6 +1282,7 @@
12731282
54A0352B20A3B3D7003E0143 /* status_test_util.h */,
12741283
54A0352D20A3B3D7003E0143 /* statusor_test.cc */,
12751284
358C3B5FE573B1D60A4F7592 /* strerror_test.cc */,
1285+
4C73C0CC6F62A90D8573F383 /* string_apple_benchmark.mm */,
12761286
0EE5300F8233D14025EF0456 /* string_apple_test.mm */,
12771287
9CFD366B783AE27B9E79EE7A /* string_format_apple_test.mm */,
12781288
54131E9620ADE678001DF3FF /* string_format_test.cc */,
@@ -2388,6 +2398,7 @@
23882398
inputPaths = (
23892399
"${PODS_ROOT}/Target Support Files/Pods-Firestore_Tests_tvOS/Pods-Firestore_Tests_tvOS-frameworks.sh",
23902400
"${BUILT_PRODUCTS_DIR}/leveldb-library-tvOS/leveldb.framework",
2401+
"${BUILT_PRODUCTS_DIR}/GoogleBenchmark-tvOS/GoogleBenchmark.framework",
23912402
"${BUILT_PRODUCTS_DIR}/GoogleTest-tvOS/GoogleTest.framework",
23922403
"${BUILT_PRODUCTS_DIR}/OCMock-tvOS/OCMock.framework",
23932404
"${BUILT_PRODUCTS_DIR}/ProtobufCpp-tvOS/ProtobufCpp.framework",
@@ -2397,6 +2408,7 @@
23972408
);
23982409
outputPaths = (
23992410
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework",
2411+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleBenchmark.framework",
24002412
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleTest.framework",
24012413
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework",
24022414
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ProtobufCpp.framework",
@@ -2504,13 +2516,15 @@
25042516
inputPaths = (
25052517
"${PODS_ROOT}/Target Support Files/Pods-Firestore_Tests_iOS/Pods-Firestore_Tests_iOS-frameworks.sh",
25062518
"${BUILT_PRODUCTS_DIR}/leveldb-library-iOS/leveldb.framework",
2519+
"${BUILT_PRODUCTS_DIR}/GoogleBenchmark-iOS/GoogleBenchmark.framework",
25072520
"${BUILT_PRODUCTS_DIR}/GoogleTest-iOS/GoogleTest.framework",
25082521
"${BUILT_PRODUCTS_DIR}/OCMock-iOS/OCMock.framework",
25092522
"${BUILT_PRODUCTS_DIR}/ProtobufCpp-iOS/ProtobufCpp.framework",
25102523
);
25112524
name = "[CP] Embed Pods Frameworks";
25122525
outputPaths = (
25132526
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework",
2527+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleBenchmark.framework",
25142528
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleTest.framework",
25152529
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework",
25162530
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ProtobufCpp.framework",
@@ -2527,7 +2541,7 @@
25272541
);
25282542
inputPaths = (
25292543
"${PODS_ROOT}/Target Support Files/Pods-Firestore_Benchmarks_iOS/Pods-Firestore_Benchmarks_iOS-frameworks.sh",
2530-
"${BUILT_PRODUCTS_DIR}/GoogleBenchmark/GoogleBenchmark.framework",
2544+
"${BUILT_PRODUCTS_DIR}/GoogleBenchmark-iOS/GoogleBenchmark.framework",
25312545
);
25322546
name = "[CP] Embed Pods Frameworks";
25332547
outputPaths = (
@@ -2723,6 +2737,7 @@
27232737
inputPaths = (
27242738
"${PODS_ROOT}/Target Support Files/Pods-Firestore_Tests_macOS/Pods-Firestore_Tests_macOS-frameworks.sh",
27252739
"${BUILT_PRODUCTS_DIR}/leveldb-library-macOS/leveldb.framework",
2740+
"${BUILT_PRODUCTS_DIR}/GoogleBenchmark-macOS/GoogleBenchmark.framework",
27262741
"${BUILT_PRODUCTS_DIR}/GoogleTest-macOS/GoogleTest.framework",
27272742
"${BUILT_PRODUCTS_DIR}/OCMock-macOS/OCMock.framework",
27282743
"${BUILT_PRODUCTS_DIR}/ProtobufCpp-macOS/ProtobufCpp.framework",
@@ -2732,6 +2747,7 @@
27322747
);
27332748
outputPaths = (
27342749
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework",
2750+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleBenchmark.framework",
27352751
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleTest.framework",
27362752
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework",
27372753
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ProtobufCpp.framework",
@@ -3080,6 +3096,7 @@
30803096
4A699B93C58FDB46A308E745 /* objc_class_test_helper.mm in Sources */,
30813097
D572B4D4DBDD6B9235781646 /* objc_compatibility_apple_test.mm in Sources */,
30823098
16FE432587C1B40AF08613D2 /* objc_type_traits_apple_test.mm in Sources */,
3099+
73A76304FED6838CBFE74E0E /* ordered_code_benchmark.mm in Sources */,
30833100
72AD91671629697074F2545B /* ordered_code_test.cc in Sources */,
30843101
DB7E9C5A59CCCDDB7F0C238A /* path_test.cc in Sources */,
30853102
0455FC6E2A281BD755FD933A /* precondition_test.cc in Sources */,
@@ -3098,6 +3115,7 @@
30983115
74985DE2C7EF4150D7A455FD /* statusor_test.cc in Sources */,
30993116
C5C01A1FB216DA4BA8BF1A02 /* stream_test.mm in Sources */,
31003117
F9DC01FCBE76CD4F0453A67C /* strerror_test.cc in Sources */,
3118+
37C4BF11C8B2B8B54B5ED138 /* string_apple_benchmark.mm in Sources */,
31013119
5EFBAD082CB0F86CD0711979 /* string_apple_test.mm in Sources */,
31023120
56D85436D3C864B804851B15 /* string_format_apple_test.mm in Sources */,
31033121
1F998DDECB54A66222CC66AA /* string_format_test.cc in Sources */,
@@ -3251,6 +3269,7 @@
32513269
D6826E6A53030C44EA0741DE /* objc_class_test_helper.mm in Sources */,
32523270
7400AC9377419A28B782B5EC /* objc_compatibility_apple_test.mm in Sources */,
32533271
9AC28D928902C6767A11F5FC /* objc_type_traits_apple_test.mm in Sources */,
3272+
9A5100FFDA685B5F0748EA4E /* ordered_code_benchmark.mm in Sources */,
32543273
FD8EA96A604E837092ACA51D /* ordered_code_test.cc in Sources */,
32553274
0963F6D7B0F9AE1E24B82866 /* path_test.cc in Sources */,
32563275
152543FD706D5E8851C8DA92 /* precondition_test.cc in Sources */,
@@ -3269,6 +3288,7 @@
32693288
DC48407370E87F2233D7AB7E /* statusor_test.cc in Sources */,
32703289
215643858470A449D3A3E168 /* stream_test.mm in Sources */,
32713290
69ED7BC38B3F981DE91E7933 /* strerror_test.cc in Sources */,
3291+
C71AD99EE8D176614E742FD7 /* string_apple_benchmark.mm in Sources */,
32723292
0087625FD31D76E1365C589E /* string_apple_test.mm in Sources */,
32733293
7A7EC216A0015D7620B4FF3E /* string_format_apple_test.mm in Sources */,
32743294
392F527F144BADDAC69C5485 /* string_format_test.cc in Sources */,
@@ -3497,6 +3517,7 @@
34973517
5542632E76A0C17B61399B54 /* objc_class_test_helper.mm in Sources */,
34983518
B6968590221770F100271095 /* objc_compatibility_apple_test.mm in Sources */,
34993519
C80B10E79CDD7EF7843C321E /* objc_type_traits_apple_test.mm in Sources */,
3520+
649B9E65663480F45DDBA021 /* ordered_code_benchmark.mm in Sources */,
35003521
AB380D04201BC6E400D97691 /* ordered_code_test.cc in Sources */,
35013522
5A080105CCBFDB6BF3F3772D /* path_test.cc in Sources */,
35023523
549CCA5920A36E1F00BCEB75 /* precondition_test.cc in Sources */,
@@ -3515,6 +3536,7 @@
35153536
54A0353020A3B3D8003E0143 /* statusor_test.cc in Sources */,
35163537
B66D8996213609EE0086DA0C /* stream_test.mm in Sources */,
35173538
1CAA9012B25F975D445D5978 /* strerror_test.cc in Sources */,
3539+
87B5AC3EBF0E83166B142FA4 /* string_apple_benchmark.mm in Sources */,
35183540
36FD4CE79613D18BC783C55B /* string_apple_test.mm in Sources */,
35193541
0535C1B65DADAE1CE47FA3CA /* string_format_apple_test.mm in Sources */,
35203542
54131E9720ADE679001DF3FF /* string_format_test.cc in Sources */,

Firestore/Example/Podfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ target 'Firestore_Example_iOS' do
5454
target 'Firestore_Tests_iOS' do
5555
inherit! :search_paths
5656

57+
pod 'GoogleBenchmark', :podspec => 'GoogleBenchmark.podspec'
5758
pod 'GoogleTest', :podspec => 'GoogleTest.podspec'
5859
pod 'ProtobufCpp', :podspec => 'ProtobufCpp.podspec'
5960

@@ -99,6 +100,7 @@ target 'Firestore_Example_macOS' do
99100
target 'Firestore_Tests_macOS' do
100101
inherit! :search_paths
101102

103+
pod 'GoogleBenchmark', :podspec => 'GoogleBenchmark.podspec'
102104
pod 'GoogleTest', :podspec => 'GoogleTest.podspec'
103105
pod 'ProtobufCpp', :podspec => 'ProtobufCpp.podspec'
104106

@@ -126,6 +128,7 @@ target 'Firestore_Example_tvOS' do
126128
target 'Firestore_Tests_tvOS' do
127129
inherit! :search_paths
128130

131+
pod 'GoogleBenchmark', :podspec => 'GoogleBenchmark.podspec'
129132
pod 'GoogleTest', :podspec => 'GoogleTest.podspec'
130133
pod 'ProtobufCpp', :podspec => 'ProtobufCpp.podspec'
131134

Firestore/core/src/firebase/firestore/util/ordered_code.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#include "absl/base/internal/unaligned_access.h"
2323
#include "absl/base/port.h"
2424

25+
#if !defined(ABSL_IS_LITTLE_ENDIAN) && !defined(ABSL_IS_BIG_ENDIAN)
26+
#error \
27+
"Unsupported byte order: Either ABSL_IS_BIG_ENDIAN or " \
28+
"ABSL_IS_LITTLE_ENDIAN must be defined"
29+
#endif
30+
2531
#define UNALIGNED_LOAD32 ABSL_INTERNAL_UNALIGNED_LOAD32
2632
#define UNALIGNED_LOAD64 ABSL_INTERNAL_UNALIGNED_LOAD64
2733
#define UNALIGNED_STORE32 ABSL_INTERNAL_UNALIGNED_STORE32
@@ -125,8 +131,8 @@ inline static int AdvanceIfNoSpecialBytes(uint32_t v_32, const char* p) {
125131
inline static const char* SkipToNextSpecialByte(const char* start,
126132
const char* limit) {
127133
// If these constants were ever changed, this routine needs to change
128-
HARD_ASSERT(kEscape1 == 0);
129-
HARD_ASSERT((kEscape2 & 0xff) == 255);
134+
static_assert(kEscape1 == 0, "bit fiddling needs readjusting");
135+
static_assert((kEscape2 & 0xff) == 255, "bit fiddling needs readjusting");
130136
const char* p = start;
131137
while (p + 8 <= limit) {
132138
// Find out if any of the next 8 bytes are either 0 or 255 (our
@@ -153,7 +159,7 @@ inline static const char* SkipToNextSpecialByte(const char* start,
153159
p += 8;
154160
} else {
155161
// We know the next 8 bytes have a special byte: find it
156-
#ifdef IS_LITTLE_ENDIAN
162+
#ifdef ABSL_IS_LITTLE_ENDIAN
157163
uint32_t v_32 = static_cast<uint32_t>(v); // Low 32 bits of v
158164
#else
159165
uint32_t v_32 = UNALIGNED_LOAD32(p);

Firestore/core/test/firebase/firestore/util/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,27 @@ cc_library(
190190
firebase_firestore_util
191191
grpc++
192192
)
193+
194+
# Benchmarks
195+
196+
cc_binary(
197+
firebase_firestore_util_ordered_code_benchmark
198+
SOURCES
199+
ordered_code_benchmark.mm
200+
DEPENDS
201+
benchmark
202+
benchmark_main
203+
firebase_firestore_util
204+
)
205+
206+
if(APPLE)
207+
cc_binary(
208+
firebase_firestore_util_string_apple_benchmark
209+
SOURCES
210+
string_apple_benchmark.mm
211+
DEPENDS
212+
benchmark
213+
benchmark_main
214+
firebase_firestore_util_base_apple
215+
)
216+
endif()

0 commit comments

Comments
 (0)