Codebergdnkl
foot
master
1#!/usr/bin/env python3
3import argparse
6class Codepoint:
7 def __init__(self, start: int, end: None | int = None):
8 self.start = start
9 self.end = start if end is None else end
10 self.vs15 = False
11 self.vs16 = False
13 def __repr__(self) -> str:
14 return f'{self.start:x}-{self.end:x}, vs15={self.vs15}, vs16={self.vs16}'
17def main() -> None:
18 parser = argparse.ArgumentParser()
19 parser.add_argument('input', type=argparse.FileType('r'))
20 parser.add_argument('output', type=argparse.FileType('w'))
21 opts = parser.parse_args()
23 codepoints: dict[int, Codepoint] = {}
25 for line in opts.input:
26 line = line.rstrip()
27 if not line:
28 continue
29 if line[0] == '#':
30 continue
32 # Example: "0023 FE0E ; text style; # (1.1) NUMBER SIGN"
33 cps, _ = line.split(';', maxsplit=1) # cps = "0023 FE0F "
34 cps = cps.strip().split(' ') # cps = ["0023", "FE0F"]
36 if len(cps) != 2:
37 raise NotImplementedError(f'emoji variation sequences with more than one base codepoint: {cps}')
39 cp, vs = cps # cp = "0023", vs = "FE0F"
40 cp = int(cp, 16) # cp = 0x23
41 vs = int(vs, 16) # vs = 0xfe0f
43 assert vs in [0xfe0e, 0xfe0f]
45 if cp not in codepoints:
46 codepoints[cp] = Codepoint(cp)
48 assert codepoints[cp].start == cp
50 if vs == 0xfe0e:
51 codepoints[cp].vs15 = True
52 else:
53 codepoints[cp].vs16 = True
55 sorted_list = sorted(codepoints.values(), key=lambda cp: cp.start)
57 compacted: list[Codepoint] = []
58 for i, cp in enumerate(sorted_list):
59 assert cp.end == cp.start
61 if i == 0:
62 compacted.append(cp)
63 continue
65 last_cp = compacted[-1]
66 if last_cp.end == cp.start - 1 and last_cp.vs15 == cp.vs15 and last_cp.vs16 == cp.vs16:
67 compacted[-1].end = cp.start
68 else:
69 compacted.append(cp)
71 opts.output.write('#pragma once\n')
72 opts.output.write('#include <stdint.h>\n')
73 opts.output.write('#include <stdbool.h>\n')
74 opts.output.write('\n')
75 opts.output.write('struct emoji_vs {\n')
76 opts.output.write(' uint32_t start:21;\n')
77 opts.output.write(' uint32_t end:21;\n')
78 opts.output.write(' bool vs15:1;\n')
79 opts.output.write(' bool vs16:1;\n')
80 opts.output.write('} __attribute__((packed));\n')
81 opts.output.write('_Static_assert(sizeof(struct emoji_vs) == 6, "unexpected struct size");\n')
82 opts.output.write('\n')
83 opts.output.write('#if defined(FOOT_GRAPHEME_CLUSTERING)\n')
84 opts.output.write('\n')
86 opts.output.write(f'static const struct emoji_vs emoji_vs[{len(compacted)}] = {{\n')
88 for cp in compacted:
89 opts.output.write(' {\n')
90 opts.output.write(f' .start = 0x{cp.start:X},\n')
91 opts.output.write(f' .end = 0x{cp.end:x},\n')
92 opts.output.write(f' .vs15 = {"true" if cp.vs15 else "false"},\n')
93 opts.output.write(f' .vs16 = {"true" if cp.vs16 else "false"},\n')
94 opts.output.write(' },\n')
96 opts.output.write('};\n')
97 opts.output.write('\n')
98 opts.output.write('#endif /* FOOT_GRAPHEME_CLUSTERING */\n')
101if __name__ == '__main__':
102 main()
Diagnostics5 git calls · 1.4 s
CallStatusSizeTime01.4 s
discover200178 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=178 git.server.agent=git/2.56.1-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=178 git.pkt.payload.max=35
ls-refs20010 KiB605 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=585 git.response.bytes=10322 git.response.cache=EXPIRED git.response.duration_ms=605 git.protocol.version=2 git.pkt.frames=108 git.pkt.data=107 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=10322 git.pkt.payload.max=106 git.ls_refs.count=107 git.ls_refs.head=refs/heads/master
fetchcombine:blob:none+tree:2 · deepen 12008.6 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=8830 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=combine:blob:none+tree:2 git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=8830 git.pkt.payload.max=8730 git.sideband.band1.bytes=8730 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=14 git.pack.bytes=8730 git.fetch.wide.objects=14 git.fetch.wide.extra_bytes=9909 git.fetch.wide.blobs=0
fetchtree:0 · deepen 102009.3 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=9489 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=9489 git.pkt.payload.max=9389 git.sideband.band1.bytes=9389 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=10 git.pack.bytes=9389 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=de930681b6073ba5b599a0f956bfbd114762ad5a git.pack.full=10Open pack map
fetch2001.2 KiB777 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=777 git.response.bytes=1208 git.response.cache=MISS git.response.duration_ms=777 git.fetch.wants=57e881c72a03387ed902cb3f856e7c924cc158a9 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1208 git.pkt.payload.max=1181 git.sideband.band1.bytes=1181 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://codeberg.org/dnkl/foot
- Ref
- refs/heads/master
- Commit
- c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
- cf-ray
- a5e19267686fddf0
- Request
- 78a9540a…
- Protocol
- v2 · sha1
- Agent
- git/2.56.1-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format