本文整理汇总了C++中LIKELY函数的典型用法代码示例。如果您正苦于以下问题:C++ LIKELY函数的具体用法?C++ LIKELY怎么用?C++ LIKELY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LIKELY函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: initThread
// Reallocates a chunk. We can save on a new allocation if the new requested
// size still fits in the chunk.
void *reallocate(void *OldPtr, uptr NewSize) {
if (UNLIKELY(!ThreadInited))
initThread();
UnpackedHeader OldHeader;
uptr Size = getUsableSize(OldPtr, &OldHeader);
uptr ChunkBeg = reinterpret_cast<uptr>(OldPtr);
ScudoChunk *Chunk =
reinterpret_cast<ScudoChunk *>(ChunkBeg - ChunkHeaderSize);
if (OldHeader.AllocType != FromMalloc) {
dieWithMessage("ERROR: invalid chunk type when reallocating address %p\n",
Chunk);
}
UnpackedHeader NewHeader = OldHeader;
// The new size still fits in the current chunk.
if (NewSize <= Size) {
NewHeader.RequestedSize = NewSize;
Chunk->compareExchangeHeader(&NewHeader, &OldHeader);
return OldPtr;
}
// Otherwise, we have to allocate a new chunk and copy the contents of the
// old one.
void *NewPtr = allocate(NewSize, MinAlignment, FromMalloc);
if (NewPtr) {
uptr OldSize = OldHeader.RequestedSize;
memcpy(NewPtr, OldPtr, Min(NewSize, OldSize));
NewHeader.State = ChunkQuarantine;
Chunk->compareExchangeHeader(&NewHeader, &OldHeader);
if (LIKELY(!ThreadTornDown)) {
AllocatorQuarantine.Put(&ThreadQuarantineCache,
QuarantineCallback(&Cache), Chunk, OldSize);
} else {
SpinMutexLock l(&FallbackMutex);
AllocatorQuarantine.Put(&FallbackQuarantineCache,
QuarantineCallback(&FallbackAllocatorCache),
Chunk, OldSize);
}
}
return NewPtr;
}
开发者ID:CSI-LLVM,项目名称:compiler-rt,代码行数:41,代码来源:scudo_allocator.cpp
示例2: m_file
File::File(const char *fileName, Mode mode) :
m_file(::open(fileName, 0)),
m_size(0),
m_cTime(0),
m_mTime(0),
m_aTime(0),
m_permissions(0)
{
if (isValid())
{
struct stat st;
if (LIKELY(::fstat(m_file, &st) != -1))
{
m_size = st.st_size;
m_cTime = st.st_ctime;
m_mTime = st.st_mtime;
m_aTime = st.st_atime;
m_permissions = translatePermissions(st);
}
}
}
开发者ID:vilkov,项目名称:lvfs-core,代码行数:22,代码来源:lvfs_core_File.cpp
示例3: filterRootById
static ContainerNode& filterRootById(ContainerNode& rootNode, const CSSSelector& firstSelector)
{
if (!rootNode.inDocument())
return rootNode;
if (rootNode.document().inQuirksMode())
return rootNode;
// If there was an Id match in the rightmost Simple Selector, we should be in a RightMostWithIdMatch, not in filter.
// Thus we can skip the rightmost match.
const CSSSelector* selector = &firstSelector;
do {
ASSERT(selector->match() != CSSSelector::Id);
if (selector->relation() != CSSSelector::SubSelector)
break;
selector = selector->tagHistory();
} while (selector);
bool inAdjacentChain = false;
for (; selector; selector = selector->tagHistory()) {
if (selector->match() == CSSSelector::Id) {
const AtomicString& idToMatch = selector->value();
if (ContainerNode* searchRoot = rootNode.treeScope().getElementById(idToMatch)) {
if (LIKELY(!rootNode.treeScope().containsMultipleElementsWithId(idToMatch))) {
if (inAdjacentChain)
searchRoot = searchRoot->parentNode();
if (searchRoot && (isTreeScopeRoot(rootNode) || searchRoot == &rootNode || searchRoot->isDescendantOf(&rootNode)))
return *searchRoot;
}
}
}
if (selector->relation() == CSSSelector::SubSelector)
continue;
if (selector->relation() == CSSSelector::DirectAdjacent || selector->relation() == CSSSelector::IndirectAdjacent)
inAdjacentChain = true;
else
inAdjacentChain = false;
}
return rootNode;
}
开发者ID:ikiw,项目名称:webkit,代码行数:39,代码来源:SelectorQuery.cpp
示例4: supportsToArray
bool supportsToArray(ObjectData* obj) {
if (obj->isCollection()) {
assertx(isValidCollection(obj->collectionType()));
return true;
} else if (UNLIKELY(obj->getAttribute(ObjectData::CallToImpl))) {
return obj->instanceof(SimpleXMLElement_classof());
} else if (UNLIKELY(obj->instanceof(SystemLib::s_ArrayObjectClass))) {
return true;
} else if (UNLIKELY(obj->instanceof(SystemLib::s_ArrayIteratorClass))) {
return true;
} else if (UNLIKELY(obj->instanceof(c_Closure::classof()))) {
return true;
} else if (UNLIKELY(obj->instanceof(DateTimeData::getClass()))) {
return true;
} else {
if (LIKELY(!obj->hasInstanceDtor())) {
return true;
}
return false;
}
}
开发者ID:GokuMizuno,项目名称:hhvm,代码行数:22,代码来源:ext_heapgraph.cpp
示例5: GetOut
void flext_base::ToSysAtom(int n,const t_atom &at) const
{
outlet *o = GetOut(n);
if(LIKELY(o)) {
CRITON();
if(IsSymbol(at))
outlet_symbol((t_outlet *)o,const_cast<t_symbol *>(GetSymbol(at)));
else if(IsFloat(at))
outlet_float((t_outlet *)o,GetFloat(at));
#if FLEXT_SYS == FLEXT_SYS_MAX
else if(IsInt(at))
outlet_flint((t_outlet *)o,GetInt(at));
#endif
#if FLEXT_SYS == FLEXT_SYS_PD
else if(IsPointer(at))
outlet_pointer((t_outlet *)o,GetPointer(at));
#endif
else
error("Atom type not supported");
CRITOFF();
}
}
开发者ID:IcaroL2ORK,项目名称:pd,代码行数:22,代码来源:flout.cpp
示例6: getValueRef
CVarRef APCLocalArray::getValueRef(ssize_t pos) const {
APCHandle *sv = m_arr->getValue(pos);
DataType t = sv->getType();
if (!IS_REFCOUNTED_TYPE(t)) {
return APCTypedValue::fromHandle(sv)->asCVarRef();
}
if (LIKELY(m_localCache != nullptr)) {
assert(unsigned(pos) < m_arr->capacity());
TypedValue* tv = &m_localCache[pos];
if (tv->m_type != KindOfUninit) {
return tvAsCVarRef(tv);
}
} else {
static_assert(KindOfUninit == 0, "must be 0 since we use smart_calloc");
unsigned cap = m_arr->capacity();
m_localCache = (TypedValue*) smart_calloc(cap, sizeof(TypedValue));
}
TypedValue* tv = &m_localCache[pos];
tvAsVariant(tv) = sv->toLocal();
assert(tv->m_type != KindOfUninit);
return tvAsCVarRef(tv);
}
开发者ID:Hillgod,项目名称:hiphop-php,代码行数:22,代码来源:apc-local-array.cpp
示例7: unlink_material_cb
static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te,
TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
{
Material **matar = NULL;
int a, totcol = 0;
if (GS(tsep->id->name) == ID_OB) {
Object *ob = (Object *)tsep->id;
totcol = ob->totcol;
matar = ob->mat;
}
else if (GS(tsep->id->name) == ID_ME) {
Mesh *me = (Mesh *)tsep->id;
totcol = me->totcol;
matar = me->mat;
}
else if (GS(tsep->id->name) == ID_CU) {
Curve *cu = (Curve *)tsep->id;
totcol = cu->totcol;
matar = cu->mat;
}
else if (GS(tsep->id->name) == ID_MB) {
MetaBall *mb = (MetaBall *)tsep->id;
totcol = mb->totcol;
matar = mb->mat;
}
else {
BLI_assert(0);
}
if (LIKELY(matar != NULL)) {
for (a = 0; a < totcol; a++) {
if (a == te->index && matar[a]) {
matar[a]->id.us--;
matar[a] = NULL;
}
}
}
}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:39,代码来源:outliner_tools.c
示例8: DLinkList_append
void DLinkList_append(DLinkList dest, DLinkList src) {
if(UNLIKELY(src->len == 0)) {
return;
}
if(LIKELY(dest->list != NULL)) {
DLink dhead = dest->list;
DLink dtail = dhead->prev;
DLink shead = src->list;
DLink stail = shead->prev;
dtail->next = shead;
shead->prev = dtail;
stail->next = dhead;
dhead->prev = stail;
} else {
dest->list = src->list;
}
dest->len += src->len;
/* reset src list*/
src->list = NULL;
src->len = 0;
}
开发者ID:codesun,项目名称:xetn,代码行数:22,代码来源:dlinklist.c
示例9: reverse_comple
static void reverse_comple(const char* seq, char* rc) {
int32_t end = strlen(seq), start = 0;
static const int8_t rc_table[128] = {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 84, 4, 71, 4, 4, 4, 67, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 65, 65, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 84, 4, 71, 4, 4, 4, 67, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 65, 65, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
};
rc[end] = '\0';
-- end;
while (LIKELY(start < end)) {
rc[start] = (char)rc_table[(int8_t)seq[end]];
rc[end] = (char)rc_table[(int8_t)seq[start]];
++ start;
-- end;
}
if (start == end) rc[start] = (char)rc_table[(int8_t)seq[start]];
}
开发者ID:jeffdaily,项目名称:Complete-Striped-Smith-Waterman-Library,代码行数:22,代码来源:main.c
示例10: BKE_mesh_cd_validate
/**
* Duplicate of BM_mesh_cd_validate() for Mesh data.
*/
void BKE_mesh_cd_validate(Mesh *me)
{
int totlayer_mtex = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
int totlayer_uv = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
int mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY);
int uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV);
int i;
if (LIKELY(totlayer_mtex == totlayer_uv)) {
/* pass */
}
else if (totlayer_mtex < totlayer_uv) {
do {
const char *from_name = me->ldata.layers[uv_index + totlayer_mtex].name;
CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, from_name);
CustomData_set_layer_unique_name(&me->pdata, totlayer_mtex);
} while (totlayer_uv != ++totlayer_mtex);
mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY);
}
else if (totlayer_uv < totlayer_mtex) {
do {
const char *from_name = me->pdata.layers[mtex_index + totlayer_uv].name;
CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, from_name);
CustomData_set_layer_unique_name(&me->ldata, totlayer_uv);
} while (totlayer_mtex != ++totlayer_uv);
uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV);
}
BLI_assert(totlayer_mtex == totlayer_uv);
/* Check uv/tex names match as well!!! */
for (i = 0; i < totlayer_mtex; i++, mtex_index++, uv_index++) {
const char *name_src = me->pdata.layers[mtex_index].name;
const char *name_dst = me->ldata.layers[uv_index].name;
if (!STREQ(name_src, name_dst)) {
BKE_mesh_uv_cdlayer_rename_index(me, mtex_index, uv_index, -1, name_src, false);
}
}
}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:42,代码来源:mesh_validate.c
示例11: assert
void c_ExternalThreadEventWaitHandle::enterContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
// stop before corrupting unioned data
if (isFinished()) {
return;
}
// already in the more specific context?
if (LIKELY(getContextIdx() >= ctx_idx)) {
return;
}
assert(getState() == STATE_WAITING);
if (isInContext()) {
getContext()->unregisterExternalThreadEvent(m_index);
}
setContextIdx(ctx_idx);
m_index = getContext()->registerExternalThreadEvent(this);
}
开发者ID:Parent5446,项目名称:hiphop-php,代码行数:22,代码来源:external_thread_event_wait_handle.cpp
示例12: f_array_keys
Variant f_array_keys(CVarRef input, CVarRef search_value /* = null_variant */,
bool strict /* = false */) {
const auto& cell_input = *input.asCell();
if (UNLIKELY(!isContainer(cell_input))) {
goto warn;
}
{
// We treat Sets differently. For Sets, we pretend the values are
// also the keys (similar to how Set::toArray() behaves).
bool isSetType =
cell_input.m_type == KindOfObject &&
cell_input.m_data.pobj->getCollectionType() == Collection::SetType;
if (UNLIKELY(isSetType)) {
return arrayKeysSetHelper(cell_input, search_value, strict);
}
ArrayIter iter(cell_input);
if (LIKELY(!search_value.isInitialized())) {
PackedArrayInit ai(getContainerSize(cell_input));
for (; iter; ++iter) {
ai.append(iter.first());
}
return ai.toArray();
}
Array ai = Array::attach(HphpArray::MakeReserve(0));
for (; iter; ++iter) {
if ((strict && HPHP::same(iter.secondRefPlus(), search_value)) ||
(!strict && HPHP::equal(iter.secondRefPlus(), search_value))) {
ai.append(iter.first());
}
}
return ai;
}
warn:
raise_warning("array_keys() expects parameter 1 to be an array "
"or collection");
return uninit_null();
}
开发者ID:barkinet,项目名称:hhvm,代码行数:38,代码来源:ext_array.cpp
示例13: assert
void c_ContinuationWaitHandle::enterContext(context_idx_t ctx_idx) {
assert(AsioSession::Get()->getContext(ctx_idx));
// stop before corrupting unioned data
if (isFinished()) {
return;
}
// already in the more specific context?
if (LIKELY(getContextIdx() >= ctx_idx)) {
return;
}
switch (getState()) {
case STATE_BLOCKED:
// enter child into new context recursively
assert(dynamic_cast<c_WaitableWaitHandle*>(m_child.get()));
static_cast<c_WaitableWaitHandle*>(m_child.get())->enterContext(ctx_idx);
setContextIdx(ctx_idx);
break;
case STATE_SCHEDULED:
// reschedule so that we get run
setContextIdx(ctx_idx);
getContext()->schedule(this);
break;
case STATE_RUNNING: {
Object e(SystemLib::AllocInvalidOperationExceptionObject(
"Detected cross-context dependency cycle. You are trying to depend "
"on something that is running you serially."));
throw e;
}
default:
assert(false);
}
}
开发者ID:gilshwartz,项目名称:hiphop-php,代码行数:38,代码来源:continuation_wait_handle.cpp
示例14: dict_sym_iter
/* iterators */
dict_si_t
dict_sym_iter(dict_t d)
{
/* uses static state */
static BDBCUR *c;
dict_si_t res;
const void *vp;
int z[1U];
if (UNLIKELY(c == NULL)) {
c = tcbdbcurnew(d);
tcbdbcurjump(c, SYM_SPACE, sizeof(SYM_SPACE));
}
if (UNLIKELY((vp = tcbdbcurval3(c, z)) == NULL)) {
goto null;
} else if (*z != sizeof(int)) {
goto null;
}
/* otherwise fill res */
res.sid = *(const int*)vp;
if (UNLIKELY((vp = tcbdbcurkey3(c, z)) == NULL)) {
goto null;
}
/* or fill */
res.sym = vp;
/* also iterate to the next thing */
tcbdbcurnext(c);
return res;
null:
if (LIKELY(c != NULL)) {
tcbdbcurdel(c);
}
c = NULL;
return (dict_si_t){};
}
开发者ID:hroptatyr,项目名称:gandalf,代码行数:39,代码来源:gand-dict-tokyo.c
示例15: MEMHEAD_FROM_PTR
void *MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str)
{
void *newp = NULL;
if (vmemh) {
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
size_t old_len = MEM_allocN_len(vmemh);
if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) {
newp = MEM_lockfree_mallocN(len, "realloc");
}
else {
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
newp = MEM_lockfree_mallocN_aligned(
old_len,
(size_t)memh_aligned->alignment,
"realloc");
}
if (newp) {
if (len < old_len) {
/* shrink */
memcpy(newp, vmemh, len);
}
else {
/* grow (or remain same size) */
memcpy(newp, vmemh, old_len);
}
}
MEM_lockfree_freeN(vmemh);
}
else {
newp = MEM_lockfree_mallocN(len, str);
}
return newp;
}
开发者ID:UPBGE,项目名称:blender,代码行数:38,代码来源:mallocn_lockfree_impl.c
示例16: operationGetByVal
EncodedTiValue operationGetByVal(TiExcState* exec, EncodedTiValue encodedBase, EncodedTiValue encodedProperty)
{
TiValue baseValue = TiValue::decode(encodedBase);
TiValue property = TiValue::decode(encodedProperty);
if (LIKELY(baseValue.isCell())) {
TiCell* base = baseValue.asCell();
if (property.isUInt32()) {
TiGlobalData* globalData = &exec->globalData();
uint32_t i = property.asUInt32();
// FIXME: the JIT used to handle these in compiled code!
if (isTiArray(globalData, base) && asArray(base)->canGetIndex(i))
return TiValue::encode(asArray(base)->getIndex(i));
// FIXME: the JITstub used to relink this to an optimized form!
if (isTiString(globalData, base) && asString(base)->canGetIndex(i))
return TiValue::encode(asString(base)->getIndex(exec, i));
// FIXME: the JITstub used to relink this to an optimized form!
if (isTiArrayArray(globalData, base) && asByteArray(base)->canAccessIndex(i))
return TiValue::encode(asByteArray(base)->getIndex(exec, i));
return TiValue::encode(baseValue.get(exec, i));
}
if (property.isString()) {
Identifier propertyName(exec, asString(property)->value(exec));
PropertySlot slot(base);
if (base->fastGetOwnPropertySlot(exec, propertyName, slot))
return TiValue::encode(slot.getValue(exec, propertyName));
}
}
Identifier ident(exec, property.toString(exec));
return TiValue::encode(baseValue.get(exec, ident));
}
开发者ID:AngelkPetkov,项目名称:tijscore,代码行数:38,代码来源:DFGOperations.cpp
示例17:
ObjectData *FrameInjection::getObjectV() const {
// Must check first: an EvalFrame can also be
// an ObjectMethodFrame (but its still implemented
// using EvalFrameInjection).
if (UNLIKELY(isEvalFrame())) {
const Eval::EvalFrameInjection* efi =
static_cast<const Eval::EvalFrameInjection*>(this);
return efi->getThis();
}
if (LIKELY(isObjectMethodFrame())) {
const FrameInjectionObjectMethod* ofi =
static_cast<const FrameInjectionObjectMethod*>(this);
return ofi->getThis();
}
if (m_flags & PseudoMain) {
const FrameInjectionFunction *ffi =
static_cast<const FrameInjectionFunction*>(this);
return ffi->getThis();
}
return NULL;
}
开发者ID:Tacnix,项目名称:hiphop-php,代码行数:23,代码来源:frame_injection.cpp
示例18: assert
HOT_FUNC
void StringData::releaseDataSlowPath() {
assert(!isSmall());
assert(checkSane());
auto const loadedMode = mode();
if (LIKELY(loadedMode == Mode::Smart)) {
smart_free(m_data);
return;
}
if (loadedMode == Mode::Shared) {
assert(checkSane());
m_big.shared->decRef();
delist();
return;
}
assert(loadedMode == Mode::Malloc);
assert(checkSane());
free(m_data);
}
开发者ID:bnovoa,项目名称:hiphop-php,代码行数:23,代码来源:string-data.cpp
示例19: ENTER
int ConvertPipeline::handle_frame(uvc_frame_t *frame) {
ENTER();
Mutex::Autolock lock(pipeline_mutex);
if (next_pipeline) {
uvc_frame_t *copy = frame;
if (mFrameConvFunc) {
copy = get_frame(frame->actual_bytes);
if (LIKELY(copy)) {
const uvc_error_t r = mFrameConvFunc(frame, copy);
if (UNLIKELY(r)) {
LOGW("failed to convert:%d", r);
recycle_frame(copy);
copy = frame;
}
}
}
next_pipeline->queueFrame(copy);
}
RETURN(1, int);
}
开发者ID:AntonioMA,项目名称:UVCCamera,代码行数:23,代码来源:ConvertPipeline.cpp
示例20: decRefObj
void c_AsyncGeneratorWaitHandle::resume() {
// may happen if scheduled in multiple contexts
if (getState() != STATE_SCHEDULED) {
decRefObj(this);
return;
}
assert(getState() == STATE_SCHEDULED);
assert(m_child->isFinished());
setState(STATE_RUNNING);
auto const resumable = m_generator->resumable();
resumable->actRec()->setReturnVMExit();
if (LIKELY(m_child->isSucceeded())) {
// child succeeded, pass the result to the async generator
g_context->resumeAsyncFunc(resumable, m_child, m_child->getResult());
} else {
// child failed, raise the exception inside the async generator
g_context->resumeAsyncFuncThrow(resumable, m_child,
m_child->getException());
}
}
开发者ID:AojiaoZero,项目名称:hhvm,代码行数:23,代码来源:async_generator_wait_handle.cpp
注:本文中的LIKELY函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论