Univalue: Do not build JSON escape list at runtime #4715

pull jgarzik wants to merge 1 commits into bitcoin:master from jgarzik:2014_univalue_warn changing 5 files +344 −20
  1. jgarzik commented at 4:17 PM on August 17, 2014: contributor

    No need to waste startup time building something that can be done at compile time.

    This also resolves a clang++ warning originally reported in #4714, univalue/univalue_write.cpp:33:12: warning: array subscript is of type 'char' [-Wchar-subscripts] escapes['"'] = """; ^~~~

    etc.

  2. isghe commented at 4:43 PM on August 17, 2014: contributor

    It should be ok having compile time assert, asserting that: [code] compile_time_assert (0 == strcmp (escapes[static_cast<unsigned char>('"')], "\"")); [/code] etc..

    or at least a runtime assert on them.

    And yes it looks we are missing a compile time initialisation like: [code] escapes[static_cast<unsigned char>('"')] = "\""; [/code] etc..

  3. in .gitignore:None in f30b421531 outdated
      27 | @@ -28,6 +28,8 @@ src/m4/ltsugar.m4
      28 |  src/m4/ltversion.m4
      29 |  src/m4/lt~obsolete.m4
      30 |  
      31 | +src/univalue/gen
    


    sipa commented at 12:20 AM on August 18, 2014:

    gen.cpp?


    jgarzik commented at 3:24 AM on August 18, 2014:

    No, gen.cpp is not a generated file to be ignored. It definitely should be checked into git.

  4. in src/univalue/univalue_escapes.h:None in f30b421531 outdated
       0 | @@ -0,0 +1,262 @@
       1 | +// Automatically generated file. Do not modify.
    


    laanwj commented at 7:18 AM on August 18, 2014:

    Please add instructions on how to regenerate the file, or at least a mention of what is used to generate it.


    jgarzik commented at 2:37 PM on August 18, 2014:

    Updated.


    laanwj commented at 3:27 PM on August 18, 2014:

    I think it's useful to refer to gen.cpp in the generated file as well. After all, someone maintaining this will stumble on this file first.

  5. laanwj commented at 7:21 AM on August 18, 2014: member

    Ut ACK, a silly 256 lookup table can be included in the executable, no need to build it at runtime (we do the same for hex digits, base64 decode table etc...).

  6. laanwj added the label Improvement on Aug 18, 2014
  7. Univalue: Do not build JSON escape list at runtime
    No need to waste startup time building something that can be done
    at compile time.
    
    This also resolves a clang++ warning originally reported in #4714,
    univalue/univalue_write.cpp:33:12: warning: array subscript is of type 'char
    escapes['"'] = "\\"";
    ^~~~
    
    etc.
    3cceba7abb
  8. BitcoinPullTester commented at 4:02 PM on August 18, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4715_3cceba7abb22133fcaea8d4f7aaed345f0e48009/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  9. jgarzik merged this on Aug 19, 2014
  10. jgarzik closed this on Aug 19, 2014

  11. jgarzik referenced this in commit 0367329549 on Aug 19, 2014
  12. jgarzik deleted the branch on Aug 24, 2014
  13. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-20 00:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me