diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-05-20 08:06:48 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-07-01 05:40:53 -0300 |
commit | 4f5b250d4effc276157cca9b8224f9e9ca25b33c (patch) | |
tree | 6a04ab7139c6f946fe752d6e19f2068c3e28dc09 /src/nvim/os/event.c | |
parent | d6ed2b3a39a2b4ea78fe9461b640eeeca53880bf (diff) | |
download | rneovim-4f5b250d4effc276157cca9b8224f9e9ca25b33c.tar.gz rneovim-4f5b250d4effc276157cca9b8224f9e9ca25b33c.tar.bz2 rneovim-4f5b250d4effc276157cca9b8224f9e9ca25b33c.zip |
klib: Improve klist.h
- Add `kl_shift_at` macro and backing function. This can be used to shift
elements at arbitrary positions. `kl_shift` is now defined on top of the new
macro.
- Change shift/push API, now `kl_push` accepts an object as parameter and
`kl_shift` returns the object instead of a status. An assertion against
shifting at the end of a list(or empty lists) was added.
- Add `kl_iter` and `kl_iter_at` macros. `kl_iter_at` is for starting the
iteration at arbitrary positions.
Diffstat (limited to 'src/nvim/os/event.c')
-rw-r--r-- | src/nvim/os/event.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c index 4c3a4581c3..56874b495d 100644 --- a/src/nvim/os/event.c +++ b/src/nvim/os/event.c @@ -149,7 +149,7 @@ void event_push(Event event, bool deferred) // returns(user hits a key for example). To avoid this scenario, we call // uv_stop when a event is enqueued. uv_stop(uv_default_loop()); - *kl_pushp(Event, deferred ? deferred_events : immediate_events) = event; + kl_push(Event, deferred ? deferred_events : immediate_events, event); } void event_process(void) @@ -159,9 +159,8 @@ void event_process(void) static void process_events_from(klist_t(Event) *queue) { - Event event; - - while (kl_shift(Event, queue, &event) == 0) { + while (!kl_empty(queue)) { + Event event = kl_shift(Event, queue); event.handler(event); } } |