[libcxx-commits] [PATCH] D129931: [libc++][format] Use to_chars internals.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 16 04:14:21 PDT 2022


Mordante created this revision.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

The external to_chars interface does some validations already done in
format. So instead of doing the same validations again, directly call
the internals of to_chars.

This has a small size benefit

    text	   data	    bss	    dec	    hex	filename
  718800	  12472	    488	 731760	  b2a70	./formatter_int.libcxx.out-baseline
  714915	  12472	    488	 727875	  b1b43	./formatter_int.libcxx.out

And a small performance benefit for simple formatting:

  Comparing ./formatter_int.libcxx.out-baseline to ./formatter_int.libcxx.out
  Benchmark                                                               Time             CPU      Time Old      Time New       CPU Old       CPU New
  ----------------------------------------------------------------------------------------------------------------------------------------------------
  BM_Basic<uint32_t>                                                   -0.1139         -0.1125            61            54            61            54
  BM_Basic<int32_t>                                                    -0.0265         -0.0250            62            60            62            60
  BM_Basic<uint64_t>                                                   +0.0051         +0.0069            82            83            82            83
  BM_Basic<int64_t>                                                    +0.0084         +0.0101            82            83            82            83
  BM_BasicLow<__uint128_t>                                             -0.0588         -0.0572            87            82            87            82
  BM_BasicLow<__int128_t>                                              -0.0548         -0.0532            88            83            88            83
  BM_Basic<__uint128_t>                                                -0.0253         -0.0238           239           233           238           233
  BM_Basic<__int128_t>                                                 -0.0346         -0.0331           222           214           222           214


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129931

Files:
  libcxx/include/__format/formatter_integral.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129931.445225.patch
Type: text/x-patch
Size: 10172 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220716/ccb4e584/attachment-0001.bin>


More information about the libcxx-commits mailing list