mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
lib/kvec: Do not use kv_init unless needed
This commit is contained in:
parent
8cfb272c74
commit
d007c2977b
@ -628,10 +628,8 @@ int json_decode_string(const char *const buf, const size_t buf_len,
|
|||||||
convert_setup(&conv, (char_u *) "utf-8", p_enc);
|
convert_setup(&conv, (char_u *) "utf-8", p_enc);
|
||||||
conv.vc_fail = true;
|
conv.vc_fail = true;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
ValuesStack stack;
|
ValuesStack stack = KV_INITIAL_VALUE;
|
||||||
kv_init(stack);
|
ContainerStack container_stack = KV_INITIAL_VALUE;
|
||||||
ContainerStack container_stack;
|
|
||||||
kv_init(container_stack);
|
|
||||||
rettv->v_type = VAR_UNKNOWN;
|
rettv->v_type = VAR_UNKNOWN;
|
||||||
bool didcomma = false;
|
bool didcomma = false;
|
||||||
bool didcolon = false;
|
bool didcolon = false;
|
||||||
|
@ -28,8 +28,7 @@
|
|||||||
|
|
||||||
#include "kvec.h"
|
#include "kvec.h"
|
||||||
int main() {
|
int main() {
|
||||||
kvec_t(int) array;
|
kvec_t(int) array = KV_INITIAL_VALUE;
|
||||||
kv_init(array);
|
|
||||||
kv_push(array, 10); // append
|
kv_push(array, 10); // append
|
||||||
kv_a(array, 20) = 5; // dynamic
|
kv_a(array, 20) = 5; // dynamic
|
||||||
kv_A(array, 20) = 4; // static
|
kv_A(array, 20) = 4; // static
|
||||||
@ -53,7 +52,14 @@ int main() {
|
|||||||
|
|
||||||
#define kv_roundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
|
#define kv_roundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
|
||||||
|
|
||||||
#define kvec_t(type) struct { size_t size, capacity; type *items; }
|
#define KV_INITIAL_VALUE { .size = 0, .capacity = 0, .items = NULL }
|
||||||
|
|
||||||
|
#define kvec_t(type) \
|
||||||
|
struct { \
|
||||||
|
size_t size; \
|
||||||
|
size_t capacity; \
|
||||||
|
type *items; \
|
||||||
|
}
|
||||||
#define kv_init(v) ((v).size = (v).capacity = 0, (v).items = 0)
|
#define kv_init(v) ((v).size = (v).capacity = 0, (v).items = 0)
|
||||||
#define kv_destroy(v) xfree((v).items)
|
#define kv_destroy(v) xfree((v).items)
|
||||||
#define kv_A(v, i) ((v).items[(i)])
|
#define kv_A(v, i) ((v).items[(i)])
|
||||||
|
@ -574,8 +574,7 @@ static void send_event(Channel *channel,
|
|||||||
|
|
||||||
static void broadcast_event(char *name, Array args)
|
static void broadcast_event(char *name, Array args)
|
||||||
{
|
{
|
||||||
kvec_t(Channel *) subscribed;
|
kvec_t(Channel *) subscribed = KV_INITIAL_VALUE;
|
||||||
kv_init(subscribed);
|
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
|
|
||||||
map_foreach_value(channels, channel, {
|
map_foreach_value(channels, channel, {
|
||||||
|
Loading…
Reference in New Issue
Block a user