Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::StringHasher Class Reference

#include <object.h>

Inheritance diagram for dart::StringHasher:
dart::ValueObject

Public Member Functions

 StringHasher ()
 
void Add (uint16_t code_unit)
 
void Add (const uint8_t *code_units, intptr_t len)
 
void Add (const uint16_t *code_units, intptr_t len)
 
void Add (const String &str, intptr_t begin_index, intptr_t len)
 
intptr_t Finalize ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 10477 of file object.h.

Constructor & Destructor Documentation

◆ StringHasher()

dart::StringHasher::StringHasher ( )
inline

Definition at line 10479 of file object.h.

10479: hash_(0) {}

Member Function Documentation

◆ Add() [1/4]

void dart::StringHasher::Add ( const String str,
intptr_t  begin_index,
intptr_t  len 
)

Definition at line 23540 of file object.cc.

23540 {
23541 ASSERT(begin_index >= 0);
23542 ASSERT(len >= 0);
23543 ASSERT((begin_index + len) <= str.Length());
23544 if (len == 0) {
23545 return;
23546 }
23547 if (str.IsOneByteString()) {
23548 NoSafepointScope no_safepoint;
23549 Add(OneByteString::CharAddr(str, begin_index), len);
23550 } else if (str.IsTwoByteString()) {
23551 NoSafepointScope no_safepoint;
23552 Add(TwoByteString::CharAddr(str, begin_index), len);
23553 } else {
23554 UNREACHABLE();
23555 }
23556}
#define UNREACHABLE()
Definition assert.h:248
void Add(uint16_t code_unit)
Definition object.h:10480
#define ASSERT(E)

◆ Add() [2/4]

void dart::StringHasher::Add ( const uint16_t *  code_units,
intptr_t  len 
)
inline

Definition at line 10488 of file object.h.

10488 {
10489 while (len > 0) {
10490 Add(LoadUnaligned(code_units));
10491 code_units++;
10492 len--;
10493 }
10494 }
static T LoadUnaligned(const T *ptr)
Definition unaligned.h:14

◆ Add() [3/4]

void dart::StringHasher::Add ( const uint8_t *  code_units,
intptr_t  len 
)
inline

Definition at line 10481 of file object.h.

10481 {
10482 while (len > 0) {
10483 Add(*code_units);
10484 code_units++;
10485 len--;
10486 }
10487 }

◆ Add() [4/4]

void dart::StringHasher::Add ( uint16_t  code_unit)
inline

Definition at line 10480 of file object.h.

10480{ hash_ = CombineHashes(hash_, code_unit); }
uint32_t CombineHashes(uint32_t hash, uint32_t other_hash)
Definition hash.h:12

◆ Finalize()

intptr_t dart::StringHasher::Finalize ( )
inline

Definition at line 10496 of file object.h.

10496{ return FinalizeHash(hash_, String::kHashBits); }
static constexpr intptr_t kHashBits
Definition object.h:323
uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits=kBitsPerInt32)
Definition hash.h:20

The documentation for this class was generated from the following files: