neovim/neovim — pull request #706 by philix (2014-05-08 18:45:49+00:00)
Title: [RFC] GA_EMPTY(ga) macro to encapsulate ga->ga_len tests

This is the first of many steps to allow us to move away from `garray.c` API someday.

I used Coccinelle to automate these changes. I'm still a n00b on it, but these two semantic patches did the job.

- Replace ga->ga_len > 0 checks with !GA_EMPTY(ga)

```diff
@@
expression E;
@@

<...
(
- E.ga_len > 0
+ !GA_EMPTY(&E)
|
- E->ga_len > 0
+ !GA_EMPTY(E)
)
...>
```
- Replace ga->ga_len == 0 checks with GA_EMPTY(ga)

```diff
@@
expression E;
@@

<...
(
// E.ga_len == 0 is isomorphic to !E.ga_len
- E.ga_len == 0
+ GA_EMPTY(&E)
|
- E->ga_len == 0
+ GA_EMPTY(E)
)
...>
```