Bug 1380909 - Try to solve crash: move GetElement out of lambda. r=michal
authorJunior Hsu <juhsu@mozilla.com>
Fri, 14 Jul 2017 00:13:00 -0400
changeset 417679 d90c8018a22f87f300323648b623a6b87761145a
parent 417678 c623242b62daf626f9e45889449c175f78bd42ae
child 417680 8ff407adc162edd035a53baa5c88bc8ff887f3c0
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1380909
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1380909 - Try to solve crash: move GetElement out of lambda. r=michal
netwerk/cache2/CacheIndex.cpp
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -2734,29 +2734,28 @@ CacheIndex::InitEntryFromDiskData(CacheI
   const char *altData = aMetaData->GetElement(CacheFileUtils::kAltDataKey);
   bool hasAltData = altData ? true : false;
   if (hasAltData &&
       NS_FAILED(CacheFileUtils::ParseAlternativeDataInfo(altData, nullptr, nullptr))) {
     return NS_ERROR_FAILURE;
   }
   aEntry->SetHasAltData(hasAltData);
 
-  static auto getUint16MetaData = [&aMetaData](const char *key) -> uint16_t {
-    const char* s64 = aMetaData->GetElement(key);
-    if (s64) {
-      nsresult rv;
-      uint64_t n64 = nsCString(s64).ToInteger64(&rv);
-      MOZ_ASSERT(NS_SUCCEEDED(rv));
-      return n64 <= kIndexTimeOutOfBound ? n64 : kIndexTimeOutOfBound;
+  static auto toUint16 = [](const char *aUint16String) -> uint16_t {
+    if (!aUint16String) {
+      return kIndexTimeNotAvailable;
     }
-    return kIndexTimeNotAvailable;
+    nsresult rv;
+    uint64_t n64 = nsCString(aUint16String).ToInteger64(&rv);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
+    return n64 <= kIndexTimeOutOfBound ? n64 : kIndexTimeOutOfBound;
   };
 
-  aEntry->SetOnStartTime(getUint16MetaData("net-response-time-onstart"));
-  aEntry->SetOnStopTime(getUint16MetaData("net-response-time-onstop"));
+  aEntry->SetOnStartTime(toUint16(aMetaData->GetElement("net-response-time-onstart")));
+  aEntry->SetOnStopTime(toUint16(aMetaData->GetElement("net-response-time-onstop")));
 
   aEntry->SetFileSize(static_cast<uint32_t>(
                         std::min(static_cast<int64_t>(PR_UINT32_MAX),
                                  (aFileSize + 0x3FF) >> 10)));
   return NS_OK;
 }
 
 bool