Bug 1271483 - p12. Use StringListContains to filter notifications - r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 26 May 2016 17:01:52 +1000
changeset 302283 bbfd03f4dd55e48e79da005863abc9d1ded85dc5
parent 302282 93bc3bb0c1be31bfa9057782b7af069ac71bedf2
child 302284 2bc76d3f7827576cd8d24e0dee225fc0d61dd2f4
push id78676
push usergsquelart@mozilla.com
push dateWed, 22 Jun 2016 03:54:32 +0000
treeherdermozilla-inbound@da005aa1d83c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1271483
milestone50.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 1271483 - p12. Use StringListContains to filter notifications - r=cpearce 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,