Commit 093a2f86c for llama.cpp

commit 093a2f86c3e37c54fa3e1f9efb17b304f3433abd
Author: Daniel Bevenius <daniel.bevenius@gmail.com>
Date:   Mon Sep 14 05:24:05 2026 +0200

    common : move llama_n_rs_seq to before llama_decode (#28749)

    This commit moves the llama_n_rs_seq function call to before the
    llama_decode call and returns directly if the check is true, removing
    the setting of res and the goto statement.

    The motivation for this change is to avoid the llama_decode call if it
    is not needed.

diff --git a/common/common.cpp b/common/common.cpp
index d162a3880..d8319cd9a 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -1586,6 +1586,11 @@ common_context_seq_rm_type common_context_can_seq_rm(llama_context * ctx) {
         return COMMON_CONTEXT_SEQ_RM_TYPE_NO;
     }

+    if (llama_n_rs_seq(ctx) > 0) {
+        COM_TRC("%s", "the context supports bounded partial sequence removal\n");
+        return COMMON_CONTEXT_SEQ_RM_TYPE_RS;
+    }
+
     common_context_seq_rm_type res = COMMON_CONTEXT_SEQ_RM_TYPE_PART;

     llama_memory_clear(mem, true);
@@ -1602,12 +1607,6 @@ common_context_seq_rm_type common_context_can_seq_rm(llama_context * ctx) {
         goto done;
     }

-    if (llama_n_rs_seq(ctx) > 0) {
-        COM_TRC("%s", "the context supports bounded partial sequence removal\n");
-        res = COMMON_CONTEXT_SEQ_RM_TYPE_RS;
-        goto done;
-    }
-
     // try to remove the last tokens
     if (!llama_memory_seq_rm(mem, 0, 1, -1)) {
         COM_TRC("%s", "the context does not support partial sequence removal\n");