mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
readline's emit and EventEmitter's emit copy the listener list before running it, so that listeners added or removed during the emit don't change who runs. The copy was a malloc and a free per emitted event: per line for a readline 'line' listener. A list of at most four listeners is now copied into a stack buffer; longer lists still allocate. A new corpus program pins the snapshot semantics for lists below and above four listeners: a listener added during an emit runs from the next emit, a removed one still runs in that emit, and a once listener runs once.