Skip to content

Commit a5ef011

Browse files
committed
remove iter attribute
1 parent 1a9c56e commit a5ef011

3 files changed

Lines changed: 9 additions & 27 deletions

File tree

src/main/java/com/github/elebras1/flecs/ObserverBuilder.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class ObserverBuilder {
1616
private Query.IterCallback iterCallback;
1717
private Query.RunCallback runCallback;
1818
private Query.EntityCallback entityCallback;
19-
private Iter iter;
2019
private static final long TERM_SIZE = ecs_term_t.layout().byteSize();
2120
private static final int MAX_EVENTS = 8;
2221

@@ -26,7 +25,6 @@ public ObserverBuilder(World world) {
2625
this.desc = ecs_observer_desc_t.allocate(this.arena);
2726
this.termCount = 0;
2827
this.eventCount = 0;
29-
this.iter = null;
3028
}
3129

3230
public ObserverBuilder(World world, String name) {
@@ -163,12 +161,8 @@ public FlecsObserver iter(Query.IterCallback callback) {
163161
this.iterCallback = callback;
164162

165163
MemorySegment callbackStub = ecs_iter_action_t.allocate(it -> {
166-
if (this.iter == null) {
167-
this.iter = new Iter(it, this.world);
168-
} else {
169-
iter.setNativeIter(it);
170-
}
171-
callback.accept(this.iter);
164+
Iter iter = new Iter(it, this.world);
165+
callback.accept(iter);
172166
}, this.world.arena());
173167

174168
ecs_observer_desc_t.callback(this.desc, callbackStub);
@@ -180,12 +174,8 @@ public FlecsObserver run(Query.RunCallback callback) {
180174
this.runCallback = callback;
181175

182176
MemorySegment callbackStub = ecs_run_action_t.allocate(it -> {
183-
if (this.iter == null) {
184-
this.iter = new Iter(it, this.world);
185-
} else {
186-
iter.setNativeIter(it);
187-
}
188-
callback.accept(this.iter);
177+
Iter iter = new Iter(it, this.world);
178+
callback.accept(iter);
189179
}, this.world.arena());
190180

191181
ecs_observer_desc_t.run(this.desc, callbackStub);

src/main/java/com/github/elebras1/flecs/SystemBuilder.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public class SystemBuilder {
1717
private Query.RunCallback runCallback;
1818
private Query.EntityCallback entityCallback;
1919
private long phase = 0;
20-
private Iter iter;
2120

2221
public SystemBuilder(World world) {
2322
this.world = world;
@@ -201,16 +200,12 @@ public FlecsSystem run(Query.RunCallback callback) {
201200
this.runCallback = callback;
202201

203202
MemorySegment callbackStub = ecs_run_action_t.allocate(it -> {
204-
if (this.iter == null) {
205-
this.iter = new Iter(it, this.world);
206-
} else {
207-
this.iter.setNativeIter(it);
208-
}
209-
callback.accept(this.iter);
203+
Iter iter = new Iter(it, this.world);
204+
callback.accept(iter);
210205
}, this.world.arena());
211-
206+
212207
ecs_system_desc_t.run(this.desc, callbackStub);
213-
208+
214209
return build();
215210
}
216211

src/main/java/com/github/elebras1/flecs/TimerBuilder.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
package com.github.elebras1.flecs;
22

3-
import java.lang.foreign.Arena;
43
import java.lang.foreign.MemorySegment;
54

65
public class TimerBuilder {
76

87
private final World world;
9-
private final Arena arena;
108
private final MemorySegment desc;
119

1210
TimerBuilder(World world) {
1311
this.world = world;
14-
this.arena = Arena.ofConfined();
15-
this.desc = ecs_system_desc_t.allocate(this.arena);
12+
this.desc = ecs_system_desc_t.allocate(this.world.arena());
1613
}
1714

1815
public TimerBuilder interval(float interval) {

0 commit comments

Comments
 (0)