.clang-format
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 14 Apr 2018 16:36:15 -0700
changeset 37711 65a23cc8e75b
parent 36224 d0a3fa849cb8
permissions -rw-r--r--
cborutil: implement support for streaming encoding, bytestring decoding The vendored cbor2 package is... a bit disappointing. On the encoding side, it insists that you pass it something with a write() to send data to. That means if you want to emit data to a generator, you have to construct an e.g. io.BytesIO(), write() to it, then get the data back out. There can be non-trivial overhead involved. The encoder also doesn't support indefinite types - bytestrings, arrays, and maps that don't have a known length. Again, this is really unfortunate because it requires you to buffer the entire source and destination in memory to encode large things. On the decoding side, it supports reading indefinite length types. But it buffers them completely before returning. More sadness. This commit implements "streaming" encoders for various CBOR types. Encoding emits a generator of hunks. So you can efficiently stream encoded data elsewhere. It also implements support for emitting indefinite length bytestrings, arrays, and maps. On the decoding side, we only implement support for decoding an indefinite length bytestring from a file object. It will emit a generator of raw chunks from the source. I didn't want to reinvent so many wheels. But profiling the wire protocol revealed that the overhead of constructing io.BytesIO() instances to temporarily hold results has a non-trivial overhead. We're talking >15% of execution time for operations like "transfer the fulltexts of all files in a revision." So I can justify this effort. Fortunately, CBOR is a relatively straightforward format. And we have a reference implementation in the repo we can test against. Differential Revision: https://phab.mercurial-scm.org/D3303
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34798
e33381d95930 clang-format: configuration for the clang-format source formatter
Augie Fackler <raf@durin42.com>
parents:
diff changeset
     1
BasedOnStyle: LLVM
e33381d95930 clang-format: configuration for the clang-format source formatter
Augie Fackler <raf@durin42.com>
parents:
diff changeset
     2
IndentWidth: 8
e33381d95930 clang-format: configuration for the clang-format source formatter
Augie Fackler <raf@durin42.com>
parents:
diff changeset
     3
UseTab: ForIndentation
e33381d95930 clang-format: configuration for the clang-format source formatter
Augie Fackler <raf@durin42.com>
parents:
diff changeset
     4
BreakBeforeBraces: Linux
e33381d95930 clang-format: configuration for the clang-format source formatter
Augie Fackler <raf@durin42.com>
parents:
diff changeset
     5
AllowShortIfStatementsOnASingleLine: false
e33381d95930 clang-format: configuration for the clang-format source formatter
Augie Fackler <raf@durin42.com>
parents:
diff changeset
     6
IndentCaseLabels: false
e33381d95930 clang-format: configuration for the clang-format source formatter
Augie Fackler <raf@durin42.com>
parents:
diff changeset
     7
AllowShortBlocksOnASingleLine: false
e33381d95930 clang-format: configuration for the clang-format source formatter
Augie Fackler <raf@durin42.com>
parents:
diff changeset
     8
AllowShortFunctionsOnASingleLine: false
36224
d0a3fa849cb8 formatting: enforce system headers before local headers
Augie Fackler <augie@google.com>
parents: 34798
diff changeset
     9
IncludeCategories:
d0a3fa849cb8 formatting: enforce system headers before local headers
Augie Fackler <augie@google.com>
parents: 34798
diff changeset
    10
  - Regex:           '^<'
d0a3fa849cb8 formatting: enforce system headers before local headers
Augie Fackler <augie@google.com>
parents: 34798
diff changeset
    11
    Priority:        1
d0a3fa849cb8 formatting: enforce system headers before local headers
Augie Fackler <augie@google.com>
parents: 34798
diff changeset
    12
  - Regex:           '^"'
d0a3fa849cb8 formatting: enforce system headers before local headers
Augie Fackler <augie@google.com>
parents: 34798
diff changeset
    13
    Priority:        2