Commit d75d0dde authored by Jonathan Kew's avatar Jonathan Kew Committed by Pier Angelo Vendrame
Browse files

Bug 1958121 - Use exchange to update the SpaceFeatures flags. a=RyanVM

parent 52c79926
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1293,8 +1293,12 @@ static const hb_tag_t defaultFeatures[] = {
void gfxFont::CheckForFeaturesInvolvingSpace() const {
  gfxFontEntry::SpaceFeatures flags = gfxFontEntry::SpaceFeatures::None;

  // mFontEntry->mHasSpaceFeatures is a std::atomic<>, so we set it with
  // `exchange` to avoid a potential data race. It's ok if two threads both
  // try to set it; they'll end up with the same value, so it doesn't matter
  // that one will overwrite the other.
  auto setFlags =
      MakeScopeExit([&]() { mFontEntry->mHasSpaceFeatures = flags; });
      MakeScopeExit([&]() { mFontEntry->mHasSpaceFeatures.exchange(flags); });

  bool log = LOG_FONTINIT_ENABLED();
  TimeStamp start;