Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/intl/lwbrk/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  nsComplexBreaker.cpp

  Sprache: C
 

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "nsComplexBreaker.h"

#include <algorithm>

#include "LineBreakCache.h"
#include "MainThreadUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/UniquePtr.h"
#include "nsTHashMap.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsThreadUtils.h"

using namespace mozilla;
using namespace mozilla::intl;

void ComplexBreaker::GetBreaks(const char16_t* aText, uint32_t aLength,
                               uint8_t* aBreakBefore) {
  // It is believed that this is only called on the main thread, so we don't
  // need to lock the caching structures. A diagnostic assert is used in case
  // our tests don't exercise all code paths.
  MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread());

  MOZ_ASSERT(aText, "aText shouldn't be null");
  MOZ_ASSERT(aLength, "aLength shouldn't be zero");
  MOZ_ASSERT(aBreakBefore, "aBreakBefore shouldn't be null");

  // Check the cache.
  LineBreakCache::KeyType key{aText, aLength};
  auto entry = LineBreakCache::Cache()->Lookup(key);
  if (entry) {
    auto& breakBefore = entry.Data().mBreaks;
    LineBreakCache::CopyAndFill(breakBefore, aBreakBefore,
                                aBreakBefore + aLength);
    return;
  }

  NS_GetComplexLineBreaks(aText, aLength, aBreakBefore);

  // As a very simple memory saving measure we trim off trailing elements that
  // are false before caching.
  auto* afterLastTrue = aBreakBefore + aLength;
  while (!*(afterLastTrue - 1)) {
    if (--afterLastTrue == aBreakBefore) {
      break;
    }
  }

  entry.Set(LineBreakCache::EntryType{
      nsString(aText, aLength),
      nsTArray<uint8_t>(aBreakBefore, afterLastTrue - aBreakBefore)});
}

Messung V0.5 in Prozent
C=92 H=98 G=94

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-05) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.