瀏覽代碼

Fix Firestore build warnings (#12536)

cherylEnkidu 2 年之前
父節點
當前提交
455e7d5cee

+ 4 - 3
Firestore/core/src/local/index_backfiller.cc

@@ -13,6 +13,7 @@
 // limitations under the License.
 
 #include <algorithm>
+#include <string>
 #include <unordered_set>
 #include <utility>
 
@@ -44,7 +45,7 @@ IndexBackfiller::IndexBackfiller() {
   max_documents_to_process_ = kMaxDocumentsToProcess;
 }
 
-int IndexBackfiller::WriteIndexEntries(const LocalStore* local_store) {
+size_t IndexBackfiller::WriteIndexEntries(const LocalStore* local_store) {
   IndexManager* index_manager = local_store->index_manager();
   std::unordered_set<std::string> processed_collection_groups;
   size_t documents_remaining = max_documents_to_process_;
@@ -64,10 +65,10 @@ int IndexBackfiller::WriteIndexEntries(const LocalStore* local_store) {
   return max_documents_to_process_ - documents_remaining;
 }
 
-int IndexBackfiller::WriteEntriesForCollectionGroup(
+size_t IndexBackfiller::WriteEntriesForCollectionGroup(
     const LocalStore* local_store,
     const std::string& collection_group,
-    int documents_remaining_under_cap) const {
+    size_t documents_remaining_under_cap) const {
   IndexManager* index_manager = local_store->index_manager();
   const auto* const local_documents_view = local_store->local_documents();
 

+ 6 - 4
Firestore/core/src/local/index_backfiller.h

@@ -15,6 +15,7 @@
 #ifndef FIRESTORE_CORE_SRC_LOCAL_INDEX_BACKFILLER_H_
 #define FIRESTORE_CORE_SRC_LOCAL_INDEX_BACKFILLER_H_
 
+#include <cstddef>
 #include <string>
 
 namespace firebase {
@@ -43,7 +44,7 @@ class IndexBackfiller {
    * Writes index entries until the cap is reached. Returns the number of
    * documents processed.
    */
-  int WriteIndexEntries(const LocalStore* local_store);
+  size_t WriteIndexEntries(const LocalStore* local_store);
 
  private:
   friend class IndexBackfillerTest;
@@ -53,9 +54,10 @@ class IndexBackfiller {
    * Writes entries for the provided collection group. Returns the number of
    * documents processed.
    */
-  int WriteEntriesForCollectionGroup(const LocalStore* local_store,
-                                     const std::string& collection_group,
-                                     int documents_remaining_under_cap) const;
+  size_t WriteEntriesForCollectionGroup(
+      const LocalStore* local_store,
+      const std::string& collection_group,
+      size_t documents_remaining_under_cap) const;
 
   /** Returns the next offset based on the provided documents. */
   model::IndexOffset GetNewOffset(const model::IndexOffset& existing_offset,

+ 1 - 1
Firestore/core/src/local/local_documents_view.cc

@@ -134,7 +134,7 @@ model::DocumentMap LocalDocumentsView::GetDocumentsMatchingCollectionGroupQuery(
 LocalWriteResult LocalDocumentsView::GetNextDocuments(
     const std::string& collection_group,
     const IndexOffset& offset,
-    int count) const {
+    size_t count) const {
   auto docs = remote_document_cache_->GetAll(collection_group, offset, count);
   auto overlays = count - docs.size() > 0
                       ? document_overlay_cache_->GetOverlays(

+ 2 - 1
Firestore/core/src/local/local_documents_view.h

@@ -17,6 +17,7 @@
 #ifndef FIRESTORE_CORE_SRC_LOCAL_LOCAL_DOCUMENTS_VIEW_H_
 #define FIRESTORE_CORE_SRC_LOCAL_LOCAL_DOCUMENTS_VIEW_H_
 
+#include <cstddef>
 #include <string>
 #include <unordered_map>
 #include <vector>
@@ -98,7 +99,7 @@ class LocalDocumentsView {
    */
   local::LocalWriteResult GetNextDocuments(const std::string& collection_group,
                                            const model::IndexOffset& offset,
-                                           int count) const;
+                                           size_t count) const;
 
   /**
    * Similar to `GetDocuments`, but creates the local view from the given

+ 1 - 1
Firestore/core/src/remote/bloom_filter.cc

@@ -78,7 +78,7 @@ int32_t BloomFilter::GetBitIndex(const Hash& hash, int32_t hash_index) const {
   uint64_t bit_index = combined_hash % bit_count_uint64;
 
   HARD_ASSERT(bit_index <= INT32_MAX);
-  return bit_index;
+  return static_cast<int32_t>(bit_index);
 }
 
 bool BloomFilter::IsBitSet(int32_t index) const {