perf(input): controller polling allocates on every tick

Aperta
#500 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start with modules/input/src/controller/controller-handler.ts at the two linked ranges and trace poll() plus getStick, getPressedKeys, and getMousePosition. Check how controller state is consumed and what tests cover polling and getters. Done means polling and getter calls reuse objects where practical while preserving input behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement modules:input
Which package or utils is this feature request for?

input

Feature

Each poll() (called every tick) creates a Set, a key array, and for each pad a new state object, ~17 button objects and an axes array, even when nothing changed. getStick, getPressedKeys and getMousePosition also return new objects on every call. This is steady garbage on the game loop, against the repo's rule for per-frame code.

Where:

Evidence:

const seen = new Set<number>();
for (const index of [...this.controllers.keys()]) {
buttons: gamepad.buttons.map((button, i) => ({ ...nextButtonState(...), value: button.value })),
axes: [...gamepad.axes],
Ideal solution or implementation

Keep one ControllerState per pad and update it in place, reuse seen, and offer cached or out-parameter getters.

Alternative solutions or implementations

No response

Other context

Found during a code audit of main at be72076.

Lingua principale
TypeScript
Stelle
7
Fork
2
Merge medio
1g 17h
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NanoForge-dev/Engine

Tutte le issue di NanoForge-dev/Engine

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.