Optimize empty map cases in CPDF_CrossRefTable::UpdateInfo()

In the case where UpdateInfo() receives an empty map, that is
effectively a no-op. Just return early and avoid moving anything around.

In the cases where CPDF_CrossRefTable has an existing map that is empty,
simply take the new map in its entirety, instead of processing it one
element at a time.

Also remove the rvalue references. They are not needed in this case, per
the style guide.

Change-Id: I05ee6f768a8a22456206674ee48d57cace5fcb28
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/109730
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_cross_ref_table.cpp b/core/fpdfapi/parser/cpdf_cross_ref_table.cpp
index 68322be..31177a3 100644
--- a/core/fpdfapi/parser/cpdf_cross_ref_table.cpp
+++ b/core/fpdfapi/parser/cpdf_cross_ref_table.cpp
@@ -124,7 +124,16 @@
 }
 
 void CPDF_CrossRefTable::UpdateInfo(
-    std::map<uint32_t, ObjectInfo>&& new_objects_info) {
+    std::map<uint32_t, ObjectInfo> new_objects_info) {
+  if (new_objects_info.empty()) {
+    return;
+  }
+
+  if (objects_info_.empty()) {
+    objects_info_ = std::move(new_objects_info);
+    return;
+  }
+
   auto cur_it = objects_info_.begin();
   auto new_it = new_objects_info.begin();
   while (cur_it != objects_info_.end() && new_it != new_objects_info.end()) {
diff --git a/core/fpdfapi/parser/cpdf_cross_ref_table.h b/core/fpdfapi/parser/cpdf_cross_ref_table.h
index ad8a85c..d76e29c 100644
--- a/core/fpdfapi/parser/cpdf_cross_ref_table.h
+++ b/core/fpdfapi/parser/cpdf_cross_ref_table.h
@@ -77,7 +77,7 @@
   void SetObjectMapSize(uint32_t size);
 
  private:
-  void UpdateInfo(std::map<uint32_t, ObjectInfo>&& new_objects_info);
+  void UpdateInfo(std::map<uint32_t, ObjectInfo> new_objects_info);
   void UpdateTrailer(RetainPtr<CPDF_Dictionary> new_trailer);
 
   RetainPtr<CPDF_Dictionary> trailer_;