Flutter Engine
The Flutter Engine
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 10498 of file object.h.

Constructor & Destructor Documentation

◆ StringHasher()

dart::StringHasher::StringHasher ( )
inline

Definition at line 10500 of file object.h.

10500: 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 23461 of file object.cc.

23461 {
23462 ASSERT(begin_index >= 0);
23463 ASSERT(len >= 0);
23464 ASSERT((begin_index + len) <= str.Length());
23465 if (len == 0) {
23466 return;
23467 }
23468 if (str.IsOneByteString()) {
23469 NoSafepointScope no_safepoint;
23470 Add(OneByteString::CharAddr(str, begin_index), len);
23471 } else if (str.IsTwoByteString()) {
23472 NoSafepointScope no_safepoint;
23473 Add(TwoByteString::CharAddr(str, begin_index), len);
23474 } else {
23475 UNREACHABLE();
23476 }
23477}
#define UNREACHABLE()
Definition: assert.h:248
void Add(uint16_t code_unit)
Definition: object.h:10501
#define ASSERT(E)

◆ Add() [2/4]

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

Definition at line 10509 of file object.h.

10509 {
10510 while (len > 0) {
10511 Add(LoadUnaligned(code_units));
10512 code_units++;
10513 len--;
10514 }
10515 }
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 10502 of file object.h.

10502 {
10503 while (len > 0) {
10504 Add(*code_units);
10505 code_units++;
10506 len--;
10507 }
10508 }

◆ Add() [4/4]

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

Definition at line 10501 of file object.h.

10501{ 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 10517 of file object.h.

10517{ 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: