This commit is contained in:
gobwas 2016-01-11 10:17:19 +03:00
parent 66fc4deeeb
commit 787d8be671
8 changed files with 293 additions and 7 deletions

134
all.mem Normal file
View File

@ -0,0 +1,134 @@
heap profile: 4: 4128 [1587: 85536] @ heap/1048576
1: 1664 [1: 1664] @ 0xab02 0x9a4b 0xda960 0xd0c57 0x71507 0x2300 0x2c2cf 0x59421
1: 1664 [1: 1664] @ 0xab02 0x9a4b 0xa0214 0xba9d4 0xa0315 0xb69a1 0x5f251 0x22fb 0x2c2cf 0x59421
1: 416 [1: 416] @ 0xab02 0x9a4b 0xdae12 0xd0c57 0x71507 0x2300 0x2c2cf 0x59421
1: 384 [1: 384] @ 0x33137 0x275af 0x2d870 0x2d419 0x56c82
0: 0 [80: 1280] @ 0x11189e 0x115771 0x10f176 0x11317a 0x10f22f 0x11317a 0x10f22f 0x11317a 0x96103 0x7299a 0x72d11 0x59421
0: 0 [95: 1520] @ 0x111159 0x11540f 0x10f176 0x11317a 0x96103 0x7299a 0x72d11 0x59421
0: 0 [1: 16] @ 0x3d1e1 0x7edf0 0x800af 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 64] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 64] @ 0x3d1e1 0x7edf0 0x804d1 0x809bb 0x809bb 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x803bd 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [1: 16] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 64] @ 0x3d1e1 0x80413 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x7ef29 0x800af 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [1: 16] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x852da 0x867fc 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [1: 16] @ 0x3d1e1 0x7edf0 0x800af 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 80] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x800af 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 128] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x804d1 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [6: 192] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x7edf0 0x804d1 0x80912 0x809bb 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 80] @ 0x3d1e1 0x8144c 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 96] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x7edf0 0x800af 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 80] @ 0x3d1e1 0x7edf0 0x800af 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 80] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 64] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x804d1 0x80912 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x804d1 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x7edf0 0x800af 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x7edf0 0x800af 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 64] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 64] @ 0xd49a 0x8102c 0x81170 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 432] @ 0xd49a 0x80aca 0x809bb 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 288] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 96] @ 0x3d1e1 0x852da 0x867fc 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 576] @ 0x3d1e1 0x8144c 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 288] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 128] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x804d1 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x804d1 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 144] @ 0x3d1e1 0x80413 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 80] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x7edf0 0x804d1 0x809bb 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 80] @ 0x3d1e1 0x80413 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [16: 256] @ 0xd49a 0x80c6b 0x81170 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x804d1 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [6: 192] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [24: 1152] @ 0x8686b 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [25: 3200] @ 0x3d1e1 0x803bd 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [8: 256] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x800af 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x7edf0 0x804d1 0x809bb 0x80912 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [7: 336] @ 0x8bc1 0x8177b 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 160] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 240] @ 0xd49a 0x80aca 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 288] @ 0xd49a 0x80ea6 0x81170 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [21: 672] @ 0x85c31 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [21: 1344] @ 0x3d1e1 0x80413 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [8: 256] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x804d1 0x80912 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [1: 16] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [15: 960] @ 0x3d1e1 0x803bd 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 432] @ 0xd49a 0x80aca 0x80912 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [6: 192] @ 0xd49a 0x7f26b 0x7ee52 0x800af 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [11: 528] @ 0xd49a 0x7e2b5 0x7e152 0x7e152 0x80c93 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x80413 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x804d1 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [8: 256] @ 0x3d1e1 0x803bd 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x7edf0 0x800af 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [7: 112] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [20: 1920] @ 0x3a63 0x81746 0x96052 0x7299a 0x72d11 0x59421
0: 0 [17: 1632] @ 0x81795 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 64] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x800af 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [7: 336] @ 0xd49a 0x7ec68 0x80c93 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [2: 32] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 64] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x804d1 0x80912 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [25: 3200] @ 0x3d1e1 0x852da 0x85ca5 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [12: 384] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x800af 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [6: 192] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [16: 1024] @ 0x8569d 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [17: 816] @ 0x86767 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 240] @ 0xd49a 0x7ec68 0x7e152 0x80c93 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [33: 4224] @ 0x3d1e1 0x8144c 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [23: 1104] @ 0x85b0c 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [70: 17920] @ 0x3d1e1 0x8144c 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [8: 128] @ 0xd49a 0x80f55 0x81170 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 288] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [10: 320] @ 0x3d1e1 0x1113e4 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [6: 288] @ 0xd49a 0x80aca 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0x3d1e1 0x7ef29 0x800af 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [9: 288] @ 0x3d1e1 0x80413 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [33: 4224] @ 0x3a85 0x81746 0x96052 0x7299a 0x72d11 0x59421
0: 0 [8: 256] @ 0x3d1e1 0x80413 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [5: 160] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [12: 384] @ 0x416a7 0x4152f 0xf46f6 0xf47b5 0x11133c 0x7f19a 0x7ee52 0x804d1 0x809bb 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [6: 96] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x804d1 0x809bb 0x80912 0x813c2 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [8: 256] @ 0xd49a 0x7f26b 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [22: 1408] @ 0x3d1e1 0x80413 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 64] @ 0x3d1e1 0x7edf0 0x800af 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [4: 64] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [8: 384] @ 0xd49a 0x7e2b5 0x7e189 0x7e152 0x80c93 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [46: 11776] @ 0x3d1e1 0x852da 0x85bb8 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [16: 1024] @ 0x3d1e1 0x852da 0x85ca5 0x85729 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [6: 192] @ 0x85676 0x8183c 0x96052 0x7299a 0x72d11 0x59421
0: 0 [3: 48] @ 0xf47e5 0x11133c 0x7f19a 0x7ee52 0x800af 0x80353 0x80353 0x80353 0x80353 0x80353 0x80353 0x81388 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [11: 352] @ 0x3d1e1 0x8144c 0x815f1 0x818f0 0x96052 0x7299a 0x72d11 0x59421
0: 0 [0: 0] @ 0x3cde5 0x109195 0x109060 0x7a11f 0x77ffd 0x2296 0x2c300 0x59421
0: 0 [353: 5648] @ 0x111159 0x11540f 0x10f176 0x11317a 0x961c3 0x7299a 0x72d11 0x59421
0: 0 [94: 1504] @ 0x111159 0x11540f 0x10f176 0x11317a 0x10f22f 0x11317a 0x96103 0x7299a 0x72d11 0x59421
0: 0 [83: 1328] @ 0x11189e 0x115771 0x10f176 0x11317a 0x10f3a8 0x11317a 0x10f22f 0x11317a 0x96103 0x7299a 0x72d11 0x59421
# runtime.MemStats
# Alloc = 220352
# TotalAlloc = 838132856
# Sys = 12228920
# Lookups = 6
# Mallocs = 35829933
# Frees = 35827943
# HeapAlloc = 220352
# HeapSys = 4718592
# HeapIdle = 4235264
# HeapInuse = 483328
# HeapReleased = 0
# HeapObjects = 1990
# Stack = 524288 / 524288
# MSpan = 6496 / 65536
# MCache = 9664 / 16384
# BuckHashSys = 1468830
# NextGC = 4194304
# PauseNs = [199896 121311 274144 145253 209780 127485 234084 125082 132838 204411 140648 136654 143825 737702 308857 131437 174357 178289 240141 148834 170727 208350 177423 168739 120081 139377 134117 380000 129289 138064 195877 140303 127096 197999 186291 208582 186194 197951 160323 145326 125270 139964 254587 149459 146565 175239 152105 244973 162787 146839 147078 141902 136271 134143 138510 127968 154110 140373 141844 255518 298600 162547 255113 149953 137799 145765 161386 140578 151203 151849 267570 146562 266440 195808 122392 134147 130160 153299 179905 145710 239139 149599 147245 140461 136898 144726 140377 164532 249314 135813 179573 157021 133298 134875 136760 172674 347534 267151 161667 235714 141383 338255 140837 174447 141005 174299 153539 140594 152727 171762 139549 141396 153813 179445 140071 144533 142231 170035 1323348 248671 175885 679907 214660 151173 163776 214150 143376 256121 153222 231098 205854 175631 131511 168430 158960 184701 131414 2053339 142247 195496 203322 147441 254542 154820 143255 186110 150173 171370 173388 144342 221518 156216 200992 186793 252068 132979 138702 159809 149780 152236 160430 194454 187028 144034 202039 184261 153039 145262 172527 1716420 253176 176345 270262 214960 168810 174589 3841505 150507 167518 174597 363506 170257 192119 240510 239861 128839 190521 195587 156133 443241 141229 405959 141600 327137 323658 297972 184994 287914 131501 162560 130819 377329 198283 333242 141639 207302 129703 209506 262195 137359 273404 200370 208263 288210 151072 141586 866868 219862 230622 198107 246049 209822 175946 150311 155252 158504 202647 243517 194444 194899 216157 279155 215337 251139 179225 179922 188143 218121 186917 249753 190137 167503 141943 305263 265879 0 0 0 0 0 0 0 0 0 0 0]
# NumGC = 245
# EnableGC = true
# DebugGC = false

BIN
all.prof Normal file

Binary file not shown.

View File

@ -271,7 +271,7 @@ func compileMatchers(matchers []match.Matcher) (match.Matcher, error) {
func do(node node, s string) (m match.Matcher, err error) {
switch n := node.(type) {
case *nodeAnyOf, *nodePattern:
case *nodePattern, *nodeAnyOf:
var matchers []match.Matcher
for _, desc := range node.children() {
m, err := do(desc, s)
@ -315,7 +315,120 @@ func do(node node, s string) (m match.Matcher, err error) {
return optimize(m), nil
}
func do2(node node, s string) ([]match.Matcher, error) {
var result []match.Matcher
switch n := node.(type) {
case *nodePattern:
ways := [][]match.Matcher{[]match.Matcher{}}
for _, desc := range node.children() {
variants, err := do2(desc, s)
if err != nil {
return nil, err
}
fmt.Println("variants pat", variants)
for i, l := 0, len(ways); i < l; i++ {
for i := 0; i < len(variants); i++ {
o := optimize(variants[i])
if i == len(variants)-1 {
ways[i] = append(ways[i], o)
} else {
var w []match.Matcher
copy(w, ways[i])
ways = append(ways, append(w, o))
}
}
}
fmt.Println("ways pat", ways)
}
for _, matchers := range ways {
c, err := compileMatchers(convertMatchers(matchers, nil))
if err != nil {
return nil, err
}
result = append(result, c)
}
case *nodeAnyOf:
ways := make([][]match.Matcher, len(node.children()))
for _, desc := range node.children() {
variants, err := do2(desc, s)
if err != nil {
return nil, err
}
fmt.Println("variants any", variants)
for x, l := 0, len(ways); x < l; x++ {
for i := 0; i < len(variants); i++ {
o := optimize(variants[i])
if i == len(variants)-1 {
ways[x] = append(ways[x], o)
} else {
var w []match.Matcher
copy(w, ways[x])
ways = append(ways, append(w, o))
}
}
}
fmt.Println("ways any", ways)
}
for _, matchers := range ways {
c, err := compileMatchers(convertMatchers(matchers, nil))
if err != nil {
return nil, err
}
result = append(result, c)
}
case *nodeList:
result = append(result, match.List{n.chars, n.not})
case *nodeRange:
result = append(result, match.Range{n.lo, n.hi, n.not})
case *nodeAny:
result = append(result, match.Any{s})
case *nodeSuper:
result = append(result, match.Super{})
case *nodeSingle:
result = append(result, match.Single{s})
case *nodeText:
result = append(result, match.Raw{n.text})
default:
return nil, fmt.Errorf("could not compile tree: unknown node type")
}
for i, m := range result {
result[i] = optimize(m)
}
return result, nil
}
func compile(ast *nodePattern, s string) (Glob, error) {
// ms, err := do2(ast, s)
// if err != nil {
// return nil, err
// }
// if len(ms) == 1 {
// return ms[0], nil
// } else {
// return match.AnyOf{ms}, nil
// }
g, err := do(ast, s)
if err != nil {
return nil, err

View File

@ -124,7 +124,7 @@ func TestCompileMatchers(t *testing.T) {
}
}
func TestConvertMatchers2(t *testing.T) {
func TestConvertMatchers(t *testing.T) {
for id, test := range []struct {
in, exp []match.Matcher
}{
@ -325,6 +325,18 @@ func TestCompiler(t *testing.T) {
Right: match.Super{},
},
},
// {
// ast: pattern(
// anyOf(&nodeText{text: "a"}, &nodeText{text: "b"}),
// anyOf(&nodeText{text: "c"}, &nodeText{text: "d"}),
// ),
// result: match.AnyOf{Matchers: match.Matchers{
// match.Row{Matchers: match.Matchers{match.Raw{"a"}, match.Raw{"c"}}},
// match.Row{Matchers: match.Matchers{match.Raw{"a"}, match.Raw{"d"}}},
// match.Row{Matchers: match.Matchers{match.Raw{"b"}, match.Raw{"c"}}},
// match.Row{Matchers: match.Matchers{match.Raw{"b"}, match.Raw{"d"}}},
// }},
// },
} {
prog, err := compile(test.ast, test.sep)
if err != nil {

BIN
glob.test Executable file

Binary file not shown.

View File

@ -42,7 +42,7 @@ func TestCompilePattern(t *testing.T) {
exp match.Matcher
}{
// {
// pattern: "{http://*yandex.ru,b}",
// pattern: "{abc,def}ghi",
// exp: match.Raw{"t"},
// },
} {
@ -147,6 +147,12 @@ func TestGlob(t *testing.T) {
glob(true, "?*?", "abc"),
glob(true, "?*?", "ac"),
glob(true, "{abc,def}ghi", "defghi"),
glob(true, "{abc,abcd}a", "abcda"),
glob(true, "{a,ab}{bc,f}", "abc"),
glob(true, "{*,**}{a,b}", "ab"),
glob(false, "{*,**}{a,b}", "ac"),
glob(true, pattern_all, fixture_all),
glob(true, pattern_plain, fixture_plain),
glob(true, pattern_multiple, fixture_multiple),
@ -163,7 +169,7 @@ func TestGlob(t *testing.T) {
result := g.Match(test.match)
if result != test.should {
t.Errorf("pattern %q matching %q should be %v but got %v", test.pattern, test.match, test.should, result)
t.Errorf("pattern %q matching %q should be %v but got %v\n%s", test.pattern, test.match, test.should, result, g)
}
}
}

View File

@ -23,8 +23,29 @@ func (self AnyOf) Match(s string) bool {
return false
}
func (self AnyOf) Len() int {
//func (self AnyOf) Index(s string) (index int, segments []int) {
//
//}
func (self AnyOf) Len() (l int) {
l = -1
for _, m := range self.Matchers {
ml := m.Len()
if ml == -1 {
return -1
}
if l == -1 {
l = ml
continue
}
if l != ml {
return -1
}
}
return
}
func (self AnyOf) Kind() Kind {

View File

@ -34,5 +34,5 @@ func (self Raw) Index(s string) (index int, segments []int) {
}
func (self Raw) String() string {
return fmt.Sprintf("[raw:%s]", self.Str)
return fmt.Sprintf("<raw:%s>", self.Str)
}