mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 06:18:16 +00:00
refactor(api): redundant ml_mfp
check #26059
buf_ensure_loaded already checks `(buf->b_ml.ml_mfp != NULL)`. #25823 TODO: - #10070 #13201 All buffer-related API functions except `nvim_buf_is_loaded` (and `nvim_buf_is_valid`?) should always call `buf_ensure_loaded`. Because the _common case_ is that plugins expect the buffer to "just work"—and for the uncomon, performance-sensitive case, the script can check `nvim_buf_is_loaded` to avoid implicitly loading a buffer. - Update documentation to clarify the above semantics.
This commit is contained in:
@@ -335,13 +335,11 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load buffer first if it's not loaded
|
// Load buffer if necessary. #22670
|
||||||
if (buf->b_ml.ml_mfp == NULL) {
|
|
||||||
if (!buf_ensure_loaded(buf)) {
|
if (!buf_ensure_loaded(buf)) {
|
||||||
api_set_error(err, kErrorTypeException, "Failed to load buffer");
|
api_set_error(err, kErrorTypeException, "Failed to load buffer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool oob = false;
|
bool oob = false;
|
||||||
start = normalize_index(buf, start, true, &oob);
|
start = normalize_index(buf, start, true, &oob);
|
||||||
@@ -517,13 +515,11 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load buffer first if it's not loaded
|
// Load buffer if necessary. #22670
|
||||||
if (buf->b_ml.ml_mfp == NULL) {
|
|
||||||
if (!buf_ensure_loaded(buf)) {
|
if (!buf_ensure_loaded(buf)) {
|
||||||
api_set_error(err, kErrorTypeException, "Failed to load buffer");
|
api_set_error(err, kErrorTypeException, "Failed to load buffer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool oob = false;
|
bool oob = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user