File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
src/main/java/io/github/treesitter/jtreesitter Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -158,8 +158,9 @@ MemorySegment segment() {
158158 try (var alloc = Arena .ofConfined ()) {
159159 var length = alloc .allocate (C_INT .byteSize (), C_INT .byteAlignment ());
160160 var supertypes = ts_language_supertypes (self , length );
161- var isEmpty = length .get (C_INT , 0 ) == 0 ;
162- return isEmpty ? new short [0 ] : supertypes .toArray (C_SHORT );
161+ var size = length .get (C_INT , 0 );
162+ if (size == 0 ) return new short [0 ];
163+ return supertypes .asSlice (0 , size * C_SHORT .byteSize ()).toArray (C_SHORT );
163164 }
164165 }
165166
@@ -173,8 +174,9 @@ MemorySegment segment() {
173174 try (var alloc = Arena .ofConfined ()) {
174175 var length = alloc .allocate (C_INT .byteSize (), C_INT .byteAlignment ());
175176 var subtypes = ts_language_subtypes (self , supertype , length );
176- var isEmpty = length .get (C_INT , 0 ) == 0 ;
177- return isEmpty ? new short [0 ] : subtypes .toArray (C_SHORT );
177+ var size = length .get (C_INT , 0 );
178+ if (size == 0 ) return new short [0 ];
179+ return subtypes .asSlice (0 , size * C_SHORT .byteSize ()).toArray (C_SHORT );
178180 }
179181 }
180182
You can’t perform that action at this time.
0 commit comments