Skip to content

Commit 6b9b79d

Browse files
committed
Comment clean up
1 parent 7c4ebed commit 6b9b79d

3 files changed

Lines changed: 26 additions & 35 deletions

File tree

storage/integration_test/src/integration_test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,10 +785,9 @@ TEST_F(FirebaseStorageTest, TestList) {
785785
return;
786786
}
787787
EXPECT_EQ(list_future.error(), firebase::storage::kErrorNone);
788+
return;
788789
}
789790

790-
if (list_future.error() != firebase::storage::kErrorNone) return;
791-
792791
firebase::storage::StorageListResult result = *list_future.result();
793792
EXPECT_EQ(result.items().size(), 3);
794793
EXPECT_EQ(result.prefixes().size(), 1);

storage/src/android/storage_reference_android.cc

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -341,31 +341,24 @@ void StorageReferenceInternal::FutureCallback(JNIEnv* env, jobject result,
341341
std::vector<StorageReference> items;
342342
std::string page_token = util::JStringToString(env, page_token_jstr);
343343

344-
if (prefixes_list) {
345-
int size = env->CallIntMethod(prefixes_list,
346-
util::list::GetMethodId(util::list::kSize));
347-
for (int i = 0; i < size; ++i) {
348-
jobject ref_obj = env->CallObjectMethod(
349-
prefixes_list, util::list::GetMethodId(util::list::kGet), i);
350-
prefixes.push_back(StorageReference(
351-
new StorageReferenceInternal(data->storage, ref_obj)));
352-
env->DeleteLocalRef(ref_obj);
344+
auto process_list = [&](jobject list_obj,
345+
std::vector<StorageReference>& out_vec) {
346+
if (list_obj) {
347+
int size = env->CallIntMethod(
348+
list_obj, util::list::GetMethodId(util::list::kSize));
349+
for (int i = 0; i < size; ++i) {
350+
jobject ref_obj = env->CallObjectMethod(
351+
list_obj, util::list::GetMethodId(util::list::kGet), i);
352+
out_vec.push_back(StorageReference(
353+
new StorageReferenceInternal(data->storage, ref_obj)));
354+
env->DeleteLocalRef(ref_obj);
355+
}
356+
env->DeleteLocalRef(list_obj);
353357
}
354-
env->DeleteLocalRef(prefixes_list);
355-
}
358+
};
356359

357-
if (items_list) {
358-
int size = env->CallIntMethod(items_list,
359-
util::list::GetMethodId(util::list::kSize));
360-
for (int i = 0; i < size; ++i) {
361-
jobject ref_obj = env->CallObjectMethod(
362-
items_list, util::list::GetMethodId(util::list::kGet), i);
363-
items.push_back(StorageReference(
364-
new StorageReferenceInternal(data->storage, ref_obj)));
365-
env->DeleteLocalRef(ref_obj);
366-
}
367-
env->DeleteLocalRef(items_list);
368-
}
360+
process_list(prefixes_list, prefixes);
361+
process_list(items_list, items);
369362

370363
if (page_token_jstr) env->DeleteLocalRef(page_token_jstr);
371364

storage/src/ios/storage_reference_ios.mm

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,15 @@
474474
std::vector<StorageReference> items;
475475
NSString* next_page_token = result.pageToken;
476476

477-
for (FIRStorageReference* prefix_ref in result.prefixes) {
478-
prefixes.push_back(
479-
StorageReference(new StorageReferenceInternal(
480-
storage, std::make_unique<FIRStorageReferencePointer>(prefix_ref))));
481-
}
482-
for (FIRStorageReference* item_ref in result.items) {
483-
items.push_back(
484-
StorageReference(new StorageReferenceInternal(
485-
storage, std::make_unique<FIRStorageReferencePointer>(item_ref))));
486-
}
477+
auto process_refs = [&](NSArray<FIRStorageReference*>* refs,
478+
std::vector<StorageReference>& out_vec) {
479+
for (FIRStorageReference* ref in refs) {
480+
out_vec.push_back(StorageReference(new StorageReferenceInternal(
481+
storage, std::make_unique<FIRStorageReferencePointer>(ref))));
482+
}
483+
};
484+
process_refs(result.prefixes, prefixes);
485+
process_refs(result.items, items);
487486

488487
internal::StorageListResultInternal* list_result_internal = new internal::StorageListResultInternal(
489488
prefixes, items, next_page_token ? [next_page_token UTF8String] : "");

0 commit comments

Comments
 (0)