On 5/22/22 7:10 PM, Yegappan Lakshmanan wrote:
Hi,

On Sun, May 22, 2022 at 11:14 AM Bram Moolenaar <[email protected]> wrote:
Patch 8.2.5003
Problem:    Cannot do bitwise shifts.
Solution:   Add the >> and << operators. (Yegappan Lakshmanan, closes #8457)

Now that we have the support for the bitwise shift operators, should we add the
support for the bitwise and (&), or (|) and xor (^) operators (like
other popular languages)?
But we do have the and(), or() and xor() builtin functions for these
operations though.

- Yegappan

Is there a bit-wise "not()" function or bit "~" operator? I didn't see it.

Having the operator certainly makes the code easier to read than with function calls. I did a  test and was quite surprised to see that the function call is only around 20% slower.


0.396802 2.252702 / p            ==> "+" 17% of the loop time
0.536753 2.431641 / p            ==> and() 22% of the loop time

0.536753 0.454308 - 0.454308 / p ==> and() 18% slower than "+"
2.431641 2.252702 - 2.252702 / p ==> and() loop 8% slower than "+" loop

FUNCTION  <SNR>42_DoAnd()
    Defined: ~/experiment/vim/isn_opnr-imp.vim:18
Called 1 time
Total time:   2.431641
 Self time:   2.431641

count  total (s)   self (s)
    1              0.000000     var a = 1
    1              0.000000     var b = 2
    1              0.000001     var lim = limit
    1              0.000000     var i = 0
    1              0.000000     var res: number

10000001              0.469681     while i < lim
10000000              0.536753         res = and(a, b)
10000000              0.378225         i += 1
10000000              0.255815     endwhile

FUNCTION  <SNR>42_DoAdd()
    Defined: ~/experiment/vim/isn_opnr-imp.vim:5
Called 1 time
Total time:   2.252702
 Self time:   2.252702

count  total (s)   self (s)
    1              0.000001     var a = 1
    1              0.000001     var b = 2
    1              0.000002     var lim = limit
    1              0.000001     var i = 0
    1              0.000000     var res: number

10000001              0.460535     while i < lim
10000000              0.454308         res = a + b
10000000              0.396802         i += 1
10000000              0.142694     endwhile

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    1   2.431641             <SNR>42_DoAnd()
    1   2.252702             <SNR>42_DoAdd()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
    1              2.431641  <SNR>42_DoAnd()
    1              2.252702  <SNR>42_DoAdd()


--
--
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/c7353338-dda5-f1aa-f6de-62fe3b360c99%40raelity.com.

Raspunde prin e-mail lui