int compare()

in fatal/string/rope.h [1303:1326]


  int compare(char const *rhs) const {
    for (piece_index i = 0, pieces = pieces_.size(); i < pieces; ++i) {
      if (!*rhs) {
        return 1;
      }

      auto piece = pieces_[i].ref();
      assert(piece);

      // TODO: optimize this, either with a duff's device or some function
      for (; *rhs && piece; ++rhs, ++piece) {
        if (auto const result = static_cast<int>(*piece) - *rhs) {
          return result;
        }
      }

      if (piece) {
        assert(!*rhs);
        return 1;
      }
    }

    return -static_cast<bool>(*rhs);
  }