当前位置: 首页>>代码示例>>C++>>正文


C++ StringData::setRefCount方法代码示例

本文整理汇总了C++中StringData::setRefCount方法的典型用法代码示例。如果您正苦于以下问题:C++ StringData::setRefCount方法的具体用法?C++ StringData::setRefCount怎么用?C++ StringData::setRefCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringData的用法示例。


在下文中一共展示了StringData::setRefCount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NEW

String &String::operator+=(litstr s) {
  if (s && *s) {
    if (empty()) {
      m_px = NEW(StringData)(s, AttachLiteral);
      m_px->setRefCount(1);
    } else if (m_px->getCount() == 1) {
      m_px->append(s, strlen(s));
    } else {
      StringData* px = NEW(StringData)(m_px, s);
      px->setRefCount(1);
      decRefStr(m_px);
      m_px = px;
    }
  }
  return *this;
}
开发者ID:vincentbdb,项目名称:hiphop-php,代码行数:16,代码来源:type_string.cpp

示例2: NEW

/**
 * concat_ss will decRef the values passed in as appropriate, and it will
 * incRef the output string
 */
StringData*
concat_ss(StringData* v1, StringData* v2) {
  if (v1->getCount() > 1) {
    StringData* ret = NEW(StringData)(v1, v2);
    ret->setRefCount(1);
    decRefStr(v2);
    // Because v1->getCount() is greater than 1, we know we will never
    // have to release the string here
    v1->decRefCount();
    return ret;
  } else {
    v1->append(v2->slice());
    decRefStr(v2);
    return v1;
  }
}
开发者ID:MarkTseng,项目名称:hiphop-php,代码行数:20,代码来源:runtime.cpp

示例3: if

String &String::operator+=(const String& str) {
  if (!str.empty()) {
    if (empty()) {
      StringBase::operator=(str.m_px);
    } else if (m_px->getCount() == 1) {
      auto tmp = m_px->append(str.slice());
      if (UNLIKELY(tmp != m_px)) StringBase::operator=(tmp);
    } else {
      StringData* px = StringData::Make(m_px, str.slice());
      decRefStr(m_px);
      px->setRefCount(1);
      m_px = px;
    }
  }
  return *this;
}
开发者ID:Yermo,项目名称:hhvm,代码行数:16,代码来源:type-string.cpp

示例4: if

String &String::operator+=(litstr s) {
    if (s && *s) {
        if (empty()) {
            m_px = StringData::Make(s, CopyString);
            m_px->setRefCount(1);
        } else if (m_px->getCount() == 1) {
            auto const tmp = m_px->append(StringSlice(s, strlen(s)));
            if (UNLIKELY(tmp != m_px)) StringBase::operator=(tmp);
        } else {
            StringData* px = StringData::Make(m_px, s);
            px->setRefCount(1);
            decRefStr(m_px);
            m_px = px;
        }
    }
    return *this;
}
开发者ID:r2958,项目名称:hiphop-php,代码行数:17,代码来源:type-string.cpp

示例5: concat_ss

/**
 * concat_ss will will incRef the output string
 * and decref its first argument
 */
StringData* concat_ss(StringData* v1, StringData* v2) {
  if (v1->hasMultipleRefs()) {
    StringData* ret = StringData::Make(v1, v2);
    ret->setRefCount(1);
    // Because v1->getCount() is greater than 1, we know we will never
    // have to release the string here
    v1->decRefCount();
    return ret;
  }

  auto const ret = v1->append(v2->slice());
  if (UNLIKELY(ret != v1)) {
    assert(v1->hasExactlyOneRef());
    v1->release();
    ret->incRefCount();
  }
  return ret;
}
开发者ID:DmitrySoshnikov,项目名称:hhvm,代码行数:22,代码来源:runtime.cpp

示例6: NEW

String& String::operator+=(const StringSlice& slice) {
  if (slice.size() == 0) {
    return *this;
  }
  if (m_px && m_px->getCount() == 1) {
    m_px->append(slice);
    return *this;
  }
  if (empty()) {
    if (m_px) decRefStr(m_px);
    m_px = NEW(StringData)(slice.begin(), slice.size(), CopyString);
    m_px->setRefCount(1);
    return *this;
  }
  StringData* px = NEW(StringData)(m_px, slice);
  px->setRefCount(1);
  decRefStr(m_px);
  m_px = px;
  return *this;
}
开发者ID:silvajohnny,项目名称:hiphop-php,代码行数:20,代码来源:type_string.cpp

示例7: assert

/**
 * concat_ss will will incRef the output string
 * and decref its first argument
 */
StringData*
concat_ss(StringData* v1, StringData* v2) {
    if (v1->getCount() > 1) {
        StringData* ret = StringData::Make(v1, v2);
        ret->setRefCount(1);
        // Because v1->getCount() is greater than 1, we know we will never
        // have to release the string here
        v1->decRefCount();
        return ret;
    }

    auto const newV1 = v1->append(v2->slice());
    if (UNLIKELY(newV1 != v1)) {
        assert(v1->getCount() == 1);
        v1->release();
        newV1->incRefCount();
        return newV1;
    }
    return v1;
}
开发者ID:raygolden,项目名称:hiphop-php,代码行数:24,代码来源:runtime.cpp

示例8: decRefStr

String& String::operator+=(const StringSlice& slice) {
    if (slice.size() == 0) {
        return *this;
    }
    if (m_px && m_px->getCount() == 1) {
        auto const tmp = m_px->append(slice);
        if (UNLIKELY(tmp != m_px)) StringBase::operator=(tmp);
        return *this;
    }
    if (empty()) {
        if (m_px) decRefStr(m_px);
        m_px = StringData::Make(slice.begin(), slice.size(), CopyString);
        m_px->setRefCount(1);
        return *this;
    }
    StringData* px = StringData::Make(m_px, slice);
    px->setRefCount(1);
    decRefStr(m_px);
    m_px = px;
    return *this;
}
开发者ID:r2958,项目名称:hiphop-php,代码行数:21,代码来源:type-string.cpp

示例9: unserialize

void String::unserialize(VariableUnserializer *uns,
                         char delimiter0 /* = '"' */,
                         char delimiter1 /* = '"' */) {
  int64 size = uns->readInt();
  if (size >= RuntimeOption::MaxSerializedStringSize) {
    throw Exception("Size of serialized string (%d) exceeds max", int(size));
  }
  if (size < 0) {
    throw Exception("Size of serialized string (%d) must not be negative",
                    int(size));
  }

  char ch = uns->readChar();
  if (ch != ':') {
    throw Exception("Expected ':' but got '%c'", ch);
  }
  ch = uns->readChar();
  if (ch != delimiter0) {
    throw Exception("Expected '%c' but got '%c'", delimiter0, ch);
  }
  StringData *px = NEW(StringData)(int(size));
  MutableSlice buf = px->mutableSlice();
  ASSERT(size <= buf.len);
  uns->read(buf.ptr, size);
  px->setSize(size);
  if (m_px && m_px->decRefCount() == 0) {
    m_px->release();
  }
  m_px = px;
  px->setRefCount(1);

  ch = uns->readChar();
  if (ch != delimiter1) {
    throw Exception("Expected '%c' but got '%c'", delimiter1, ch);
  }

  checkStatic();
}
开发者ID:AviMoto,项目名称:hiphop-php,代码行数:38,代码来源:type_string.cpp


注:本文中的StringData::setRefCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。