V8 Project
v8::internal::StringComparator Class Reference
+ Collaboration diagram for v8::internal::StringComparator:

Classes

class  State
 

Public Member Functions

 StringComparator (ConsStringIteratorOp *op_1, ConsStringIteratorOp *op_2)
 
bool Equals (String *string_1, String *string_2)
 

Static Public Member Functions

template<typename Chars1 , typename Chars2 >
static bool Equals (State *state_1, State *state_2, int to_check)
 

Private Member Functions

 DISALLOW_IMPLICIT_CONSTRUCTORS (StringComparator)
 

Private Attributes

State state_1_
 
State state_2_
 

Detailed Description

Definition at line 8559 of file objects.cc.

Constructor & Destructor Documentation

◆ StringComparator()

v8::internal::StringComparator::StringComparator ( ConsStringIteratorOp op_1,
ConsStringIteratorOp op_2 
)
inline

Definition at line 8620 of file objects.cc.

8622  : state_1_(op_1),
8623  state_2_(op_2) {
8624  }

Member Function Documentation

◆ DISALLOW_IMPLICIT_CONSTRUCTORS()

v8::internal::StringComparator::DISALLOW_IMPLICIT_CONSTRUCTORS ( StringComparator  )
private

◆ Equals() [1/2]

template<typename Chars1 , typename Chars2 >
static bool v8::internal::StringComparator::Equals ( State state_1,
State state_2,
int  to_check 
)
inlinestatic

Definition at line 8627 of file objects.cc.

8627  {
8628  const Chars1* a = reinterpret_cast<const Chars1*>(state_1->buffer8_);
8629  const Chars2* b = reinterpret_cast<const Chars2*>(state_2->buffer8_);
8630  return RawStringComparator<Chars1, Chars2>::compare(a, b, to_check);
8631  }
static bool compare(const Chars1 *a, const Chars2 *b, int len)
Definition: objects.cc:8529

References v8::internal::StringComparator::State::buffer8_, and v8::internal::RawStringComparator< Chars1, Chars2 >::compare().

+ Here is the call graph for this function:

◆ Equals() [2/2]

bool v8::internal::StringComparator::Equals ( String string_1,
String string_2 
)
inline

Definition at line 8633 of file objects.cc.

8633  {
8634  int length = string_1->length();
8635  state_1_.Init(string_1);
8636  state_2_.Init(string_2);
8637  while (true) {
8638  int to_check = Min(state_1_.length_, state_2_.length_);
8639  DCHECK(to_check > 0 && to_check <= length);
8640  bool is_equal;
8641  if (state_1_.is_one_byte_) {
8642  if (state_2_.is_one_byte_) {
8643  is_equal = Equals<uint8_t, uint8_t>(&state_1_, &state_2_, to_check);
8644  } else {
8645  is_equal = Equals<uint8_t, uint16_t>(&state_1_, &state_2_, to_check);
8646  }
8647  } else {
8648  if (state_2_.is_one_byte_) {
8649  is_equal = Equals<uint16_t, uint8_t>(&state_1_, &state_2_, to_check);
8650  } else {
8651  is_equal = Equals<uint16_t, uint16_t>(&state_1_, &state_2_, to_check);
8652  }
8653  }
8654  // Looping done.
8655  if (!is_equal) return false;
8656  length -= to_check;
8657  // Exit condition. Strings are equal.
8658  if (length == 0) return true;
8659  state_1_.Advance(to_check);
8660  state_2_.Advance(to_check);
8661  }
8662  }
#define DCHECK(condition)
Definition: logging.h:205
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)

References v8::internal::StringComparator::State::Advance(), DCHECK, v8::internal::StringComparator::State::Init(), v8::internal::StringComparator::State::is_one_byte_, v8::internal::String::length(), v8::internal::StringComparator::State::length_, v8::internal::Min(), state_1_, and state_2_.

+ Here is the call graph for this function:

Member Data Documentation

◆ state_1_

State v8::internal::StringComparator::state_1_
private

Definition at line 8665 of file objects.cc.

Referenced by Equals().

◆ state_2_

State v8::internal::StringComparator::state_2_
private

Definition at line 8666 of file objects.cc.

Referenced by Equals().


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