* zeertzjq <vim-dev-git...@256bit.org> [240326 17:58]:
> Problem:  Unnecessary multiplications in backspace code, as
>           &quot;col / ts * ts&quot; is the same as &quot;col - col % ts&quot;.
> Solution: Change &quot;col / ts * ts&quot; to &quot;col - col % ts&quot;.  
> Adjust the loop
>           and the comments ins_bs() to be easier to understand.  Update
>           tests to reset &#39;smarttab&#39; properly.
> 
> You can view, comment on, or merge this pull request online at:
> 
>   https://github.com/vim/vim/pull/14308

Did you examine the assembler produced by the compiler for these?  I
expected that any reasonable optimizing compiler would produce identical
code, and in fact, gcc -O2 on amd64 (linux) does for a very simple
source program comparing them:

-------- multmod.c --------
/* multmod compares int division and modulus
 *
 * To compile to assembler with some optimization:  cc -S -O2 multmod.c
 */
#include <stdio.h>

int mult(int a, int b)
{
        return a / b * b;
}

int mod(int a, int b)
{
        return a - a % b;
}

int main(int argc, char* argv[])
{
        int a = 76;
        int b = 7;
        int c;

        c = mult(a, b);
        printf("c = %d\n", c);

        c = mod(a, b);
        printf("c = %d\n", c);
}
--------

Examining the produced assembler, mult and mod are identical (only one
idivl, with the expected subl).

It is certainly possible that for the specific source you are changing,
the compiler does not recognize the opportunity for optimization, but
until you inspect the assembler for the original code, you will not
know.  I did not actually compile to assembler and examine the code you
are changing, so I cannot say definitively.

Unless there is a reason (such a particular architecture that is giving
problems with not-good-enough optimizations), I would avoid source churn
for zero benefit.

...Marvin

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/ZgNsNtE8KOUDTzOh%40basil.wdw.

Raspunde prin e-mail lui