svn commit: r1934287 - subversion/trunk/subversion/libsvn_subr

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <177900965093.3954329.6472112462632500065@svn03-he-fi>
Author: rinrab
Date: Sun May 17 09:20:50 2026
New Revision: 1934287

Log:
Remove TODO comment about intrinsics for byte swap, instead say that modern
compilers are good enough to recognise this pattern and use proper
instructions on their own.

Confirmed on the compiler explorer [1].
I was looking at [gcc/clang/msvc]+[x86-64/arm64]

* subversion/libsvn_subr/utf.c
  (SWAP_SHORT, SWAP_LONG): Update comment.

[1] https://godbolt.org/z/Yj5ovc7zd

Modified:
   subversion/trunk/subversion/libsvn_subr/utf.c

Modified: subversion/trunk/subversion/libsvn_subr/utf.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/utf.c	Sun May 17 09:07:53 2026	(r1934286)
+++ subversion/trunk/subversion/libsvn_subr/utf.c	Sun May 17 09:20:50 2026	(r1934287)
@@ -1048,7 +1048,8 @@ membuf_insert_ucs4(svn_membuf_t *buf, ap
   ((apr_int32_t*)buf->data)[offset] = value;
 }
 
-/* TODO: Use compiler intrinsics for byte swaps. */
+/* Modern compilers with -O2 optimise it out and replace these with special
+ * instructions (bswap or rev). */
 #define SWAP_SHORT(x)  ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
 #define SWAP_LONG(x)   ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8)    \
                         | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.