mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 15:58:17 +00:00
refactor: add pure attribute to pure functions (#18165)
This will allow the compilers that support the pure attribute to make further optimizations.
This commit is contained in:
@@ -357,6 +357,7 @@ void set_bufref(bufref_T *bufref, buf_T *buf)
|
||||
///
|
||||
/// @param bufref Buffer reference to check for.
|
||||
bool bufref_valid(bufref_T *bufref)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return bufref->br_buf_free_count == buf_free_count
|
||||
? true
|
||||
@@ -2100,6 +2101,7 @@ buf_T *buflist_findname(char_u *ffname)
|
||||
///
|
||||
/// @return buffer or NULL if not found
|
||||
static buf_T *buflist_findname_file_id(char_u *ffname, FileID *file_id, bool file_id_valid)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
// Start at the last buffer, expect to find a match sooner.
|
||||
FOR_ALL_BUFFERS_BACKWARDS(buf) {
|
||||
@@ -2531,7 +2533,7 @@ static bool wininfo_other_tab_diff(wininfo_T *wip)
|
||||
///
|
||||
/// @return NULL when there isn't any info.
|
||||
static wininfo_T *find_wininfo(buf_T *buf, bool need_options, bool skip_diff_buffer)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
|
||||
{
|
||||
wininfo_T *wip;
|
||||
|
||||
@@ -2609,6 +2611,7 @@ void get_winopts(buf_T *buf)
|
||||
///
|
||||
/// @return a pointer to no_position if no position is found.
|
||||
pos_T *buflist_findfpos(buf_T *buf)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
static pos_T no_position = { 1, 0, 0 };
|
||||
|
||||
@@ -2618,6 +2621,7 @@ pos_T *buflist_findfpos(buf_T *buf)
|
||||
|
||||
/// Find the lnum for the buffer 'buf' for the current window.
|
||||
linenr_T buflist_findlnum(buf_T *buf)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return buflist_findfpos(buf)->lnum;
|
||||
}
|
||||
@@ -4928,6 +4932,7 @@ void do_arg_all(int count, int forceit, int keep_tabs)
|
||||
|
||||
/// @return true if "buf" is a prompt buffer.
|
||||
bool bt_prompt(buf_T *buf)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return buf != NULL && buf->b_p_bt[0] == 'p';
|
||||
}
|
||||
@@ -5339,6 +5344,7 @@ bool bt_dontwrite_msg(const buf_T *const buf)
|
||||
/// @return true if the buffer should be hidden, according to 'hidden', ":hide"
|
||||
/// and 'bufhidden'.
|
||||
bool buf_hide(const buf_T *const buf)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
// 'bufhidden' overrules 'hidden' and ":hide", check it first
|
||||
switch (buf->b_p_bh[0]) {
|
||||
|
Reference in New Issue
Block a user