MCPcopy Index your code
hub / github.com/python/mypy / vec_contains

Function vec_contains

mypyc/irbuild/vec.py:538–569  ·  view source on GitHub ↗
(builder: LowLevelIRBuilder, vec: Value, target: Value, line: int)

Source from the content-addressed store, hash-verified

536
537
538def vec_contains(builder: LowLevelIRBuilder, vec: Value, target: Value, line: int) -> Value:
539 assert isinstance(vec.type, RVec)
540 vec_type = vec.type
541 item_type = vec_type.item_type
542 target = builder.coerce(target, item_type, line)
543
544 step = step_size(item_type)
545 len_val = vec_len_native(builder, vec)
546 items_start = vec_items(builder, vec)
547 items_end = builder.int_add(items_start, builder.int_mul(len_val, step))
548
549 true, end = BasicBlock(), BasicBlock()
550
551 for_loop = builder.begin_for(
552 items_start, items_end, Integer(step, c_pyssize_t_rprimitive), signed=False
553 )
554 item = vec_load_mem_item(builder, for_loop.index, item_type, can_borrow=True)
555 comp = builder.binary_op(item, target, "==", line)
556 false = BasicBlock()
557 builder.add(Branch(comp, true, false, Branch.BOOL))
558 builder.activate_block(false)
559 for_loop.finish()
560
561 builder.keep_alive([vec], line)
562
563 res = Register(bool_rprimitive)
564 builder.assign(res, Integer(0, bool_rprimitive))
565 builder.goto(end)
566 builder.activate_block(true)
567 builder.assign(res, Integer(1, bool_rprimitive))
568 builder.goto_and_activate(end)
569 return res
570
571
572def vec_slice(

Callers 1

binary_opMethod · 0.90

Calls 15

BasicBlockClass · 0.90
IntegerClass · 0.90
BranchClass · 0.90
RegisterClass · 0.90
isinstanceFunction · 0.85
step_sizeFunction · 0.85
vec_len_nativeFunction · 0.85
vec_itemsFunction · 0.85
vec_load_mem_itemFunction · 0.85
int_addMethod · 0.80
int_mulMethod · 0.80
begin_forMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…