Bug 1271483 - p12. Use StringListContains to filter notifications - r=cpearce, a=lizzard
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 26 May 2016 17:01:52 +1000
changeset 339800 c99836f4707dcff72ac1f16bf99edcfb8fa61660
parent 339799 5d717e3c331f03d167c71669837fb9deb16c7b59
child 339801 e40406f3f9e9b95044dac6db4ec0ffb8fa0febce
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lizzard
bugs1271483
milestone49.0a2
Bug 1271483 - p12. Use StringListContains to filter notifications - r=cpearce, a=lizzard Using string-list iterator instead of bespoke code, to go through the decoder doctor notifications-allowed pref. MozReview-Commit-ID: 8sxopvlRrz7
dom/media/DecoderDoctorDiagnostics.cpp
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -416,32 +416,18 @@ DecoderDoctorDocumentWatcher::ReportAnal
   // may be dispatched to the front-end. It either contains:
   // - '*' -> Allow everything.
   // - Comma-separater list of ids -> Allow if aReportStringId (from
   //                                  dom.properties) is one of them.
   // - Nothing (missing or empty) -> Disable everything.
   nsAdoptingCString filter =
     Preferences::GetCString("media.decoder-doctor.notifications-allowed");
   filter.StripWhitespace();
-  bool allowed = false;
-  if (!filter || filter.IsEmpty()) {
-    // Allow nothing.
-  } else if (filter.EqualsLiteral("*")) {
-    allowed = true;
-  } else for (uint32_t start = 0; start < filter.Length(); ) {
-    int32_t comma = filter.FindChar(',', start);
-    uint32_t end = (comma >= 0) ? uint32_t(comma) : filter.Length();
-    if (strncmp(aReportStringId, filter.Data() + start, end - start) == 0) {
-      allowed = true;
-      break;
-    }
-    // Skip comma. End of line will be caught in for 'while' clause.
-    start = end + 1;
-  }
-  if (allowed) {
+  if (filter.EqualsLiteral("*")
+      || StringListContains(filter, aReportStringId)) {
     DispatchNotification(
       mDocument->GetInnerWindow(),
       aNotificationType, aIsSolved, aReportStringId, aParams);
   }
 }
 
 enum SilverlightPresence {
   eNoSilverlight,