Skip to content

Commit 7a0c881

Browse files
committed
pkg: merge Keyword.from_ptr() and Keyword.__init__()
1 parent 84e22d2 commit 7a0c881

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/pkgcraft/pkg/ebuild.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cdef class Keyword:
3838
cdef int _hash
3939

4040
@staticmethod
41-
cdef Keyword from_ptr(C.Keyword *)
41+
cdef Keyword from_ptr(C.Keyword *, Keyword inst=*)
4242

4343

4444
cdef class Maintainer(Indirect):

src/pkgcraft/pkg/ebuild.pyx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,13 @@ cdef class Keyword:
251251
if ptr is NULL:
252252
raise PkgcraftError
253253

254-
self.status = KeywordStatus(ptr.status)
255-
self.arch = ptr.arch.decode()
256-
self.ptr = ptr
254+
Keyword.from_ptr(ptr, self)
257255

258256
@staticmethod
259-
cdef Keyword from_ptr(C.Keyword *ptr):
257+
cdef Keyword from_ptr(C.Keyword *ptr, Keyword inst = None):
260258
"""Create a Keyword from a pointer."""
261-
inst = <Keyword>Keyword.__new__(Keyword)
259+
if inst is None:
260+
inst = <Keyword>Keyword.__new__(Keyword)
262261
inst.status = KeywordStatus(ptr.status)
263262
inst.arch = ptr.arch.decode()
264263
inst.ptr = ptr

0 commit comments

Comments
 (0)