Skip to content

Commit d72f951

Browse files
committed
Refactor create_ptr to remove redundant size argument
The create_ptr function in _VarArray.__cinit__ no longer takes a separate size argument and instead uses len(vars) directly. This simplifies the function signature and reduces redundancy.
1 parent 50bb995 commit d72f951

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pyscipopt/scip.pxi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,9 +2467,9 @@ cdef class _VarArray:
24672467
cdef int size
24682468

24692469
def __cinit__(self, object vars):
2470-
def create_ptr(size: int, vars: Union[list, tuple, MatrixVariable]):
2470+
def create_ptr(vars: Union[list, tuple, MatrixVariable]):
24712471
cdef SCIP_VAR** ptr
2472-
ptr = <SCIP_VAR**> malloc(self.size * sizeof(SCIP_VAR*)) if size > 0 else NULL
2472+
ptr = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*)) if len(vars) > 0 else NULL
24732473
for i, var in enumerate(vars):
24742474
if not isinstance(var, Variable):
24752475
raise TypeError(f"Expected Variable, got {type(var)}.")

0 commit comments

Comments
 (0)