mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
refactor: add pure attribute to pure functions
This will allow compilers that support the pure attribute to make further optimizations to functions.
This commit is contained in:
parent
9a35704333
commit
0fb571e3b5
@ -974,6 +974,7 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c)
|
||||
/// @param one First character.
|
||||
/// @param two Character just after "one".
|
||||
bool arabic_combine(int one, int two)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
if (one == a_LAM) {
|
||||
return arabic_maycombine(two);
|
||||
@ -984,6 +985,7 @@ bool arabic_combine(int one, int two)
|
||||
/// Check whether we are dealing with a character that could be regarded as an
|
||||
/// Arabic combining character, need to check the character before this.
|
||||
bool arabic_maycombine(int two)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
if (p_arshape && !p_tbidi) {
|
||||
return two == a_ALEF_MADDA
|
||||
|
@ -379,6 +379,7 @@ static void au_cleanup(void)
|
||||
|
||||
// Get the first AutoPat for a particular event.
|
||||
AutoPat *au_get_autopat_for_event(event_T event)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return first_autopat[(int)event];
|
||||
}
|
||||
@ -1143,6 +1144,7 @@ int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int gro
|
||||
}
|
||||
|
||||
size_t aucmd_pattern_length(char_u *pat)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
if (*pat == NUL) {
|
||||
return 0;
|
||||
@ -1175,6 +1177,7 @@ size_t aucmd_pattern_length(char_u *pat)
|
||||
}
|
||||
|
||||
char_u *aucmd_next_pattern(char_u *pat, size_t patlen)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
pat = pat + patlen;
|
||||
if (*pat == ',') {
|
||||
@ -2383,6 +2386,7 @@ theend:
|
||||
|
||||
// Checks if a pattern is buflocal
|
||||
bool aupat_is_buflocal(char_u *pat, int patlen)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return patlen >= 8
|
||||
&& STRNCMP(pat, "<buffer", 7) == 0
|
||||
@ -2492,6 +2496,7 @@ char *aucmd_exec_default_desc(AucmdExecutable acc)
|
||||
}
|
||||
|
||||
char *aucmd_exec_to_string(AutoCmd *ac, AucmdExecutable acc)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
switch (acc.type) {
|
||||
case CALLABLE_EX:
|
||||
@ -2542,6 +2547,7 @@ AucmdExecutable aucmd_exec_copy(AucmdExecutable src)
|
||||
}
|
||||
|
||||
bool aucmd_exec_is_deleted(AucmdExecutable acc)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
switch (acc.type) {
|
||||
case CALLABLE_EX:
|
||||
@ -2556,6 +2562,7 @@ bool aucmd_exec_is_deleted(AucmdExecutable acc)
|
||||
}
|
||||
|
||||
bool au_event_is_empty(event_T event)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return first_autopat[event] == NULL;
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ bool buf_updates_register(buf_T *buf, uint64_t channel_id, BufUpdateCallbacks cb
|
||||
}
|
||||
|
||||
bool buf_updates_active(buf_T *buf)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return kv_size(buf->update_channels) || kv_size(buf->update_callbacks);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ void ctx_free_all(void)
|
||||
|
||||
/// Returns the size of the context stack.
|
||||
size_t ctx_size(void)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return kv_size(ctx_stack);
|
||||
}
|
||||
@ -40,6 +41,7 @@ size_t ctx_size(void)
|
||||
/// Returns pointer to Context object with given zero-based index from the top
|
||||
/// of context stack or NULL if index is out of bounds.
|
||||
Context *ctx_get(size_t index)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
if (index < kv_size(ctx_stack)) {
|
||||
return &kv_Z(ctx_stack, index);
|
||||
|
@ -277,6 +277,7 @@ char *parse_shape_opt(int what)
|
||||
///
|
||||
/// @param exclusive If 'selection' option is "exclusive".
|
||||
bool cursor_is_block_during_visual(bool exclusive)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
int mode_idx = exclusive ? SHAPE_IDX_VE : SHAPE_IDX_V;
|
||||
return (SHAPE_BLOCK == shape_table[mode_idx].shape
|
||||
@ -300,6 +301,7 @@ int cursor_mode_str2int(const char *mode)
|
||||
|
||||
/// Check if a syntax id is used as a cursor style.
|
||||
bool cursor_mode_uses_syn_id(int syn_id)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
if (*p_guicursor == NUL) {
|
||||
return false;
|
||||
@ -316,6 +318,7 @@ bool cursor_mode_uses_syn_id(int syn_id)
|
||||
|
||||
/// Return the index into shape_table[] for the current mode.
|
||||
int cursor_get_mode_idx(void)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
if (State == SHOWMATCH) {
|
||||
return SHAPE_IDX_SM;
|
||||
|
@ -883,6 +883,7 @@ theend:
|
||||
/// diff will be used anyway.
|
||||
///
|
||||
int diff_internal(void)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return (diff_flags & DIFF_INTERNAL) != 0 && *p_dex == NUL;
|
||||
}
|
||||
@ -2250,6 +2251,7 @@ bool diffopt_horizontal(void)
|
||||
|
||||
// Return true if 'diffopt' contains "hiddenoff".
|
||||
bool diffopt_hiddenoff(void)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return (diff_flags & DIFF_HIDDEN_OFF) != 0;
|
||||
}
|
||||
|
@ -1551,6 +1551,7 @@ int get_digraph(bool cmdline)
|
||||
/// @return If no match, return "char2". If "meta_char" is true and "char1"
|
||||
// is a space, return "char2" | 0x80.
|
||||
static int getexactdigraph(int char1, int char2, bool meta_char)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
@ -1601,6 +1602,7 @@ static int getexactdigraph(int char1, int char2, bool meta_char)
|
||||
///
|
||||
/// @return The digraph.
|
||||
int digraph_get(int char1, int char2, bool meta_char)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
int retval;
|
||||
|
||||
|
@ -2604,6 +2604,7 @@ char_u *getexline(int c, void *cookie, int indent, bool do_concat)
|
||||
}
|
||||
|
||||
bool cmdline_overstrike(void)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return ccline.overstrike;
|
||||
}
|
||||
@ -2611,6 +2612,7 @@ bool cmdline_overstrike(void)
|
||||
|
||||
/// Return true if the cursor is at the end of the cmdline.
|
||||
bool cmdline_at_end(void)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return (ccline.cmdpos >= ccline.cmdlen);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user