| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Lexer.pm |
| Statements | Executed 3180679 statements in 2.45s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 61194 | 10 | 1 | 585ms | 682ms | YAML::PP::Lexer::_push_tokens |
| 27707 | 3 | 1 | 397ms | 827ms | YAML::PP::Lexer::_fetch_next_tokens |
| 18718 | 1 | 1 | 384ms | 1.49s | YAML::PP::Lexer::fetch_plain |
| 18360 | 3 | 1 | 175ms | 295ms | YAML::PP::Lexer::_fetch_next_line |
| 13356 | 1 | 1 | 168ms | 785ms | YAML::PP::Lexer::fetch_next_tokens |
| 58385 | 19 | 1 | 154ms | 154ms | YAML::PP::Lexer::CORE:regcomp (opcode) |
| 75042 | 16 | 1 | 148ms | 148ms | YAML::PP::Lexer::CORE:subst (opcode) |
| 159492 | 22 | 1 | 59.9ms | 59.9ms | YAML::PP::Lexer::line |
| 2045 | 1 | 1 | 50.4ms | 198ms | YAML::PP::Lexer::fetch_quoted |
| 2046 | 2 | 1 | 48.4ms | 52.5ms | YAML::PP::Lexer::push_subtokens |
| 2045 | 1 | 1 | 35.4ms | 47.2ms | YAML::PP::Lexer::_read_quoted_tokens |
| 76597 | 4 | 2 | 32.4ms | 32.4ms | YAML::PP::Lexer::next_tokens |
| 63240 | 2 | 1 | 31.1ms | 31.1ms | YAML::PP::Lexer::set_offset |
| 75588 | 7 | 2 | 30.1ms | 30.1ms | YAML::PP::Lexer::flowcontext |
| 63240 | 2 | 1 | 21.8ms | 21.8ms | YAML::PP::Lexer::offset |
| 13361 | 2 | 1 | 19.3ms | 19.3ms | YAML::PP::Lexer::CORE:match (opcode) |
| 39124 | 4 | 1 | 17.6ms | 17.6ms | YAML::PP::Lexer::next_line |
| 37139 | 1 | 1 | 15.7ms | 15.7ms | YAML::PP::Lexer::context |
| 26721 | 8 | 1 | 13.9ms | 13.9ms | YAML::PP::Lexer::set_next_line |
| 13360 | 1 | 1 | 8.25ms | 8.25ms | YAML::PP::Lexer::set_block |
| 13361 | 1 | 1 | 7.02ms | 7.02ms | YAML::PP::Lexer::reader |
| 13924 | 1 | 1 | 6.82ms | 6.82ms | YAML::PP::Lexer::block |
| 13360 | 1 | 1 | 6.09ms | 6.09ms | YAML::PP::Lexer::inc_line |
| 1 | 1 | 1 | 2.69ms | 2.93ms | YAML::PP::Lexer::BEGIN@10 |
| 1090 | 1 | 1 | 741µs | 741µs | YAML::PP::Lexer::set_flowcontext |
| 1 | 1 | 1 | 94µs | 272µs | YAML::PP::Lexer::fetch_block |
| 176 | 2 | 1 | 85µs | 85µs | YAML::PP::Lexer::set_context |
| 1 | 1 | 1 | 36µs | 41µs | YAML::PP::Parser::BEGIN@1 |
| 11 | 8 | 1 | 29µs | 29µs | YAML::PP::Lexer::CORE:qr (opcode) |
| 1 | 1 | 1 | 9µs | 27µs | YAML::PP::Lexer::BEGIN@11 |
| 1 | 1 | 1 | 9µs | 44µs | YAML::PP::Parser::BEGIN@2.286 |
| 3 | 3 | 2 | 8µs | 8µs | YAML::PP::Lexer::init |
| 1 | 1 | 1 | 6µs | 12µs | YAML::PP::Lexer::new |
| 1 | 1 | 1 | 5µs | 46µs | YAML::PP::Lexer::BEGIN@7 |
| 1 | 1 | 1 | 4µs | 4µs | YAML::PP::Lexer::set_reader |
| 1 | 1 | 1 | 3µs | 18µs | YAML::PP::Lexer::BEGIN@8 |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Lexer::_fetch_next_tokens_directive |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Lexer::_read_doublequoted |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Lexer::exception |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Lexer::set_line |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 42µs | 2 | 46µs | # spent 41µs (36+5) within YAML::PP::Parser::BEGIN@1 which was called:
# once (36µs+5µs) by YAML::PP::Parser::BEGIN@18 at line 1 # spent 41µs making 1 call to YAML::PP::Parser::BEGIN@1
# spent 5µs making 1 call to strict::import |
| 2 | 2 | 51µs | 2 | 79µs | # spent 44µs (9+35) within YAML::PP::Parser::BEGIN@2.286 which was called:
# once (9µs+35µs) by YAML::PP::Parser::BEGIN@18 at line 2 # spent 44µs making 1 call to YAML::PP::Parser::BEGIN@2.286
# spent 35µs making 1 call to warnings::import |
| 3 | package YAML::PP::Lexer; | ||||
| 4 | |||||
| 5 | 1 | 1µs | our $VERSION = '0.035'; # VERSION | ||
| 6 | |||||
| 7 | 2 | 25µs | 2 | 87µs | # spent 46µs (5+41) within YAML::PP::Lexer::BEGIN@7 which was called:
# once (5µs+41µs) by YAML::PP::Parser::BEGIN@18 at line 7 # spent 46µs making 1 call to YAML::PP::Lexer::BEGIN@7
# spent 41µs making 1 call to constant::import |
| 8 | 2 | 16µs | 2 | 33µs | # spent 18µs (3+15) within YAML::PP::Lexer::BEGIN@8 which was called:
# once (3µs+15µs) by YAML::PP::Parser::BEGIN@18 at line 8 # spent 18µs making 1 call to YAML::PP::Lexer::BEGIN@8
# spent 15µs making 1 call to constant::import |
| 9 | |||||
| 10 | 2 | 545µs | 2 | 3.05ms | # spent 2.93ms (2.69+235µs) within YAML::PP::Lexer::BEGIN@10 which was called:
# once (2.69ms+235µs) by YAML::PP::Parser::BEGIN@18 at line 10 # spent 2.93ms making 1 call to YAML::PP::Lexer::BEGIN@10
# spent 121µs making 1 call to Exporter::import |
| 11 | 2 | 4.35ms | 2 | 45µs | # spent 27µs (9+18) within YAML::PP::Lexer::BEGIN@11 which was called:
# once (9µs+18µs) by YAML::PP::Parser::BEGIN@18 at line 11 # spent 27µs making 1 call to YAML::PP::Lexer::BEGIN@11
# spent 18µs making 1 call to Exporter::import |
| 12 | |||||
| 13 | # spent 12µs (6+6) within YAML::PP::Lexer::new which was called:
# once (6µs+6µs) by YAML::PP::Parser::new at line 29 of YAML/PP/Parser.pm | ||||
| 14 | 1 | 1µs | my ($class, %args) = @_; | ||
| 15 | my $self = bless { | ||||
| 16 | reader => $args{reader}, | ||||
| 17 | 1 | 2µs | }, $class; | ||
| 18 | 1 | 1µs | 1 | 6µs | $self->init; # spent 6µs making 1 call to YAML::PP::Lexer::init |
| 19 | 1 | 2µs | return $self; | ||
| 20 | } | ||||
| 21 | |||||
| 22 | # spent 8µs within YAML::PP::Lexer::init which was called 3 times, avg 3µs/call:
# once (6µs+0s) by YAML::PP::Lexer::new at line 18
# once (1µs+0s) by YAML::PP::Parser::init at line 115 of YAML/PP/Parser.pm
# once (1µs+0s) by YAML::PP::Parser::parse at line 151 of YAML/PP/Parser.pm | ||||
| 23 | 3 | 1µs | my ($self) = @_; | ||
| 24 | 3 | 3µs | $self->{next_tokens} = []; | ||
| 25 | 3 | 0s | $self->{next_line} = undef; | ||
| 26 | 3 | 1µs | $self->{line} = 0; | ||
| 27 | 3 | 1µs | $self->{offset} = 0; | ||
| 28 | 3 | 5µs | $self->{flowcontext} = 0; | ||
| 29 | } | ||||
| 30 | |||||
| 31 | 39124 | 44.7ms | # spent 17.6ms within YAML::PP::Lexer::next_line which was called 39124 times, avg 449ns/call:
# 18718 times (8.69ms+0s) by YAML::PP::Lexer::fetch_plain at line 367, avg 464ns/call
# 18360 times (7.85ms+0s) by YAML::PP::Lexer::_fetch_next_line at line 136, avg 427ns/call
# 2045 times (1.02ms+0s) by YAML::PP::Lexer::fetch_quoted at line 620, avg 499ns/call
# once (1µs+0s) by YAML::PP::Lexer::fetch_block at line 519 | ||
| 32 | 26721 | 32.0ms | # spent 13.9ms within YAML::PP::Lexer::set_next_line which was called 26721 times, avg 520ns/call:
# 13360 times (6.27ms+0s) by YAML::PP::Lexer::_fetch_next_line at line 150, avg 469ns/call
# 6344 times (3.56ms+0s) by YAML::PP::Lexer::fetch_plain at line 398, avg 561ns/call
# 4998 times (2.97ms+0s) by YAML::PP::Lexer::fetch_plain at line 392, avg 594ns/call
# 1413 times (765µs+0s) by YAML::PP::Lexer::fetch_quoted at line 706, avg 541ns/call
# 598 times (330µs+0s) by YAML::PP::Lexer::fetch_quoted at line 697, avg 552ns/call
# 6 times (1µs+0s) by YAML::PP::Lexer::fetch_block at line 561, avg 167ns/call
# once (1µs+0s) by YAML::PP::Lexer::_fetch_next_line at line 143
# once (1µs+0s) by YAML::PP::Lexer::fetch_next_tokens at line 221 | ||
| 33 | 13361 | 14.3ms | # spent 7.02ms within YAML::PP::Lexer::reader which was called 13361 times, avg 525ns/call:
# 13361 times (7.02ms+0s) by YAML::PP::Lexer::_fetch_next_line at line 141, avg 525ns/call | ||
| 34 | 1 | 5µs | # spent 4µs within YAML::PP::Lexer::set_reader which was called:
# once (4µs+0s) by YAML::PP::Parser::set_reader at line 70 of YAML/PP/Parser.pm | ||
| 35 | 76597 | 78.7ms | # spent 32.4ms within YAML::PP::Lexer::next_tokens which was called 76597 times, avg 423ns/call:
# 61194 times (26.4ms+0s) by YAML::PP::Lexer::_push_tokens at line 880, avg 431ns/call
# 13356 times (5.04ms+0s) by YAML::PP::Lexer::fetch_next_tokens at line 182, avg 378ns/call
# 2046 times (977µs+0s) by YAML::PP::Lexer::push_subtokens at line 906, avg 478ns/call
# once (2µs+0s) by YAML::PP::Parser::parse_tokens at line 344 of YAML/PP/Parser.pm | ||
| 36 | 159492 | 164ms | # spent 59.9ms within YAML::PP::Lexer::line which was called 159492 times, avg 376ns/call:
# 61194 times (19.7ms+0s) by YAML::PP::Lexer::_push_tokens at line 881, avg 322ns/call
# 18718 times (9.18ms+0s) by YAML::PP::Lexer::fetch_plain at line 381, avg 490ns/call
# 18718 times (6.89ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 355, avg 368ns/call
# 13953 times (4.75ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 295, avg 340ns/call
# 13354 times (5.26ms+0s) by YAML::PP::Lexer::fetch_next_tokens at line 217, avg 394ns/call
# 7533 times (3.49ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 307, avg 463ns/call
# 6420 times (2.93ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 303, avg 457ns/call
# 4998 times (2.12ms+0s) by YAML::PP::Lexer::fetch_plain at line 391, avg 424ns/call
# 2046 times (719µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 278, avg 351ns/call
# 2046 times (657µs+0s) by YAML::PP::Lexer::push_subtokens at line 907, avg 321ns/call
# 2045 times (1.01ms+0s) by YAML::PP::Lexer::_read_quoted_tokens at line 742, avg 494ns/call
# 2045 times (903µs+0s) by YAML::PP::Lexer::fetch_quoted at line 626, avg 442ns/call
# 2045 times (663µs+0s) by YAML::PP::Lexer::_read_quoted_tokens at line 748, avg 324ns/call
# 1756 times (561µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 340, avg 319ns/call
# 1413 times (564µs+0s) by YAML::PP::Lexer::fetch_quoted at line 704, avg 399ns/call
# 666 times (302µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 336, avg 453ns/call
# 523 times (208µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 256, avg 398ns/call
# 15 times (4µs+0s) by YAML::PP::Lexer::fetch_block at line 605, avg 267ns/call
# once (2µs+0s) by YAML::PP::Lexer::fetch_next_tokens at line 208
# once (1µs+0s) by YAML::PP::Lexer::fetch_block at line 548
# once (0s+0s) by YAML::PP::Lexer::fetch_block at line 526
# once (0s+0s) by YAML::PP::Lexer::fetch_block at line 538 | ||
| 37 | sub set_line { $_[0]->{line} = $_[1] } | ||||
| 38 | 63240 | 61.6ms | sub offset { return $_[0]->{offset} } | ||
| 39 | 63240 | 75.6ms | sub set_offset { $_[0]->{offset} = $_[1] } | ||
| 40 | 13360 | 14.7ms | # spent 6.09ms within YAML::PP::Lexer::inc_line which was called 13360 times, avg 456ns/call:
# 13360 times (6.09ms+0s) by YAML::PP::Lexer::_fetch_next_line at line 147, avg 456ns/call | ||
| 41 | 37139 | 41.2ms | # spent 15.7ms within YAML::PP::Lexer::context which was called 37139 times, avg 424ns/call:
# 37139 times (15.7ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 263, avg 424ns/call | ||
| 42 | 176 | 182µs | sub set_context { $_[0]->{context} = $_[1] } | ||
| 43 | 75588 | 82.4ms | # spent 30.1ms within YAML::PP::Lexer::flowcontext which was called 75588 times, avg 399ns/call:
# 20764 times (7.97ms+0s) by YAML::PP::Parser::parse_tokens at line 379 of YAML/PP/Parser.pm, avg 384ns/call
# 18718 times (6.25ms+0s) by YAML::PP::Lexer::fetch_plain at line 371, avg 334ns/call
# 13953 times (6.65ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 286, avg 476ns/call
# 13354 times (6.14ms+0s) by YAML::PP::Lexer::fetch_next_tokens at line 208, avg 460ns/call
# 4998 times (1.61ms+0s) by YAML::PP::Lexer::fetch_plain at line 405, avg 322ns/call
# 2045 times (875µs+0s) by YAML::PP::Lexer::fetch_quoted at line 694, avg 428ns/call
# 1756 times (645µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 342, avg 367ns/call | ||
| 44 | 1090 | 1.45ms | # spent 741µs within YAML::PP::Lexer::set_flowcontext which was called 1090 times, avg 680ns/call:
# 1090 times (741µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 343, avg 680ns/call | ||
| 45 | 13924 | 14.8ms | # spent 6.82ms within YAML::PP::Lexer::block which was called 13924 times, avg 490ns/call:
# 13924 times (6.82ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 286, avg 490ns/call | ||
| 46 | 13360 | 15.8ms | # spent 8.25ms within YAML::PP::Lexer::set_block which was called 13360 times, avg 618ns/call:
# 13360 times (8.25ms+0s) by YAML::PP::Lexer::_fetch_next_line at line 146, avg 618ns/call | ||
| 47 | |||||
| 48 | 1 | 1µs | my $RE_WS = '[\t ]'; | ||
| 49 | 1 | 0s | my $RE_LB = '[\r\n]'; | ||
| 50 | 1 | 45µs | 2 | 27µs | my $RE_DOC_END = qr/\A(\.\.\.)(?=$RE_WS|$)/m; # spent 22µs making 1 call to YAML::PP::Lexer::CORE:regcomp
# spent 5µs making 1 call to YAML::PP::Lexer::CORE:qr |
| 51 | 1 | 21µs | 2 | 14µs | my $RE_DOC_START = qr/\A(---)(?=$RE_WS|$)/m; # spent 12µs making 1 call to YAML::PP::Lexer::CORE:regcomp
# spent 2µs making 1 call to YAML::PP::Lexer::CORE:qr |
| 52 | 1 | 157µs | 2 | 144µs | my $RE_EOL = qr/\A($RE_WS+#.*|$RE_WS+)\z/; # spent 141µs making 1 call to YAML::PP::Lexer::CORE:regcomp
# spent 3µs making 1 call to YAML::PP::Lexer::CORE:qr |
| 53 | #my $RE_COMMENT_EOL = qr/\A(#.*)?(?:$RE_LB|\z)/; | ||||
| 54 | |||||
| 55 | #ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” | ||||
| 56 | 1 | 0s | my $RE_NS_WORD_CHAR = '[0-9A-Za-z-]'; | ||
| 57 | 1 | 0s | my $RE_URI_CHAR = '(?:' . '%[0-9a-fA-F]{2}' .'|'. q{[0-9A-Za-z#;/?:@&=+$,_.!*'\(\)\[\]-]} . ')'; | ||
| 58 | 1 | 0s | my $RE_NS_TAG_CHAR = '(?:' . '%[0-9a-fA-F]{2}' .'|'. q{[0-9A-Za-z#;/?:@&=+$_.~*'\(\)-]} . ')'; | ||
| 59 | |||||
| 60 | # [#x21-#x7E] /* 8 bit */ | ||||
| 61 | # | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] /* 16 bit */ | ||||
| 62 | # | [#x10000-#x10FFFF] /* 32 bit */ | ||||
| 63 | |||||
| 64 | #nb-char ::= c-printable - b-char - c-byte-order-mark | ||||
| 65 | #my $RE_NB_CHAR = '[\x21-\x7E]'; | ||||
| 66 | 1 | 1µs | my $RE_ANCHOR_CAR = '[\x21-\x2B\x2D-\x5A\x5C\x5E-\x7A\x7C\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; | ||
| 67 | |||||
| 68 | 1 | 0s | my $RE_PLAIN_START = '[\x21\x22\x24-\x39\x3B-\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; | ||
| 69 | 1 | 1µs | my $RE_PLAIN_END = '[\x21-\x39\x3B-\x7E\x85\xA0-\x{D7FF}\x{E000}-\x{FEFE}\x{FF00}-\x{FFFD}\x{10000}-\x{10FFFF}]'; | ||
| 70 | 1 | 0s | my $RE_PLAIN_FIRST = '[\x24\x28-\x29\x2B\x2E-\x39\x3B-\x3D\x41-\x5A\x5C\x5E-\x5F\x61-\x7A\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; | ||
| 71 | |||||
| 72 | 1 | 1µs | my $RE_PLAIN_START_FLOW = '[\x21\x22\x24-\x2B\x2D-\x39\x3B-\x5A\x5C\x5E-\x7A\x7C\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; | ||
| 73 | 1 | 0s | my $RE_PLAIN_END_FLOW = '[\x21-\x2B\x2D-\x39\x3B-\x5A\x5C\x5E-\x7A\x7C\x7E\x85\xA0-\x{D7FF}\x{E000}-\x{FEFE}\x{FF00}-\x{FFFD}\x{10000}-\x{10FFFF}]'; | ||
| 74 | 1 | 1µs | my $RE_PLAIN_FIRST_FLOW = '[\x24\x28-\x29\x2B\x2E-\x39\x3B-\x3D\x41-\x5A\x5C\x5E-\x5F\x61-\x7A\x7C\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; | ||
| 75 | # c-indicators | ||||
| 76 | #! 21 | ||||
| 77 | #" 22 | ||||
| 78 | ## 23 | ||||
| 79 | #% 25 | ||||
| 80 | #& 26 | ||||
| 81 | #' 27 | ||||
| 82 | #* 2A | ||||
| 83 | #, 2C FLOW | ||||
| 84 | #- 2D XX | ||||
| 85 | #: 3A XX | ||||
| 86 | #> 3E | ||||
| 87 | #? 3F XX | ||||
| 88 | #@ 40 | ||||
| 89 | #[ 5B FLOW | ||||
| 90 | #] 5D FLOW | ||||
| 91 | #` 60 | ||||
| 92 | #{ 7B FLOW | ||||
| 93 | #| 7C | ||||
| 94 | #} 7D FLOW | ||||
| 95 | |||||
| 96 | |||||
| 97 | 1 | 2µs | my $RE_PLAIN_WORD = "(?::+$RE_PLAIN_END|$RE_PLAIN_START)(?::+$RE_PLAIN_END|$RE_PLAIN_END)*"; | ||
| 98 | 1 | 0s | my $RE_PLAIN_FIRST_WORD = "(?:[:?-]+$RE_PLAIN_END|$RE_PLAIN_FIRST)(?::+$RE_PLAIN_END|$RE_PLAIN_END)*"; | ||
| 99 | 1 | 0s | my $RE_PLAIN_WORDS = "(?:$RE_PLAIN_FIRST_WORD(?:$RE_WS+$RE_PLAIN_WORD)*)"; | ||
| 100 | 1 | 0s | my $RE_PLAIN_WORDS2 = "(?:$RE_PLAIN_WORD(?:$RE_WS+$RE_PLAIN_WORD)*)"; | ||
| 101 | |||||
| 102 | 1 | 1µs | my $RE_PLAIN_WORD_FLOW = "(?::+$RE_PLAIN_END_FLOW|$RE_PLAIN_START_FLOW)(?::+$RE_PLAIN_END_FLOW|$RE_PLAIN_END_FLOW)*"; | ||
| 103 | 1 | 1µs | my $RE_PLAIN_FIRST_WORD_FLOW = "(?:[:?-]+$RE_PLAIN_END_FLOW|$RE_PLAIN_FIRST_FLOW)(?::+$RE_PLAIN_END_FLOW|$RE_PLAIN_END_FLOW)*"; | ||
| 104 | 1 | 4µs | my $RE_PLAIN_WORDS_FLOW = "(?:$RE_PLAIN_FIRST_WORD_FLOW(?:$RE_WS+$RE_PLAIN_WORD_FLOW)*)"; | ||
| 105 | 1 | 0s | my $RE_PLAIN_WORDS_FLOW2 = "(?:$RE_PLAIN_WORD_FLOW(?:$RE_WS+$RE_PLAIN_WORD_FLOW)*)"; | ||
| 106 | |||||
| 107 | |||||
| 108 | #c-secondary-tag-handle ::= “!” “!” | ||||
| 109 | #c-named-tag-handle ::= “!” ns-word-char+ “!” | ||||
| 110 | #ns-tag-char ::= ns-uri-char - “!” - c-flow-indicator | ||||
| 111 | #ns-global-tag-prefix ::= ns-tag-char ns-uri-char* | ||||
| 112 | #c-ns-local-tag-prefix ::= “!” ns-uri-char* | ||||
| 113 | 1 | 1µs | my $RE_TAG = "!(?:$RE_NS_WORD_CHAR*!$RE_NS_TAG_CHAR+|$RE_NS_TAG_CHAR+|<$RE_URI_CHAR+>|)"; | ||
| 114 | |||||
| 115 | #c-ns-anchor-property ::= “&” ns-anchor-name | ||||
| 116 | #ns-char ::= nb-char - s-white | ||||
| 117 | #ns-anchor-char ::= ns-char - c-flow-indicator | ||||
| 118 | #ns-anchor-name ::= ns-anchor-char+ | ||||
| 119 | |||||
| 120 | 1 | 44µs | 2 | 20µs | my $RE_SEQSTART = qr/\A(-)(?=$RE_WS|$)/m; # spent 18µs making 1 call to YAML::PP::Lexer::CORE:regcomp
# spent 2µs making 1 call to YAML::PP::Lexer::CORE:qr |
| 121 | 1 | 19µs | 2 | 13µs | my $RE_COMPLEX = qr/(\?)(?=$RE_WS|$)/m; # spent 12µs making 1 call to YAML::PP::Lexer::CORE:regcomp
# spent 1µs making 1 call to YAML::PP::Lexer::CORE:qr |
| 122 | 1 | 18µs | 2 | 14µs | my $RE_COMPLEXCOLON = qr/\A(:)(?=$RE_WS|$)/m; # spent 13µs making 1 call to YAML::PP::Lexer::CORE:regcomp
# spent 1µs making 1 call to YAML::PP::Lexer::CORE:qr |
| 123 | 1 | 0s | my $RE_ANCHOR = "&$RE_ANCHOR_CAR+"; | ||
| 124 | 1 | 0s | my $RE_ALIAS = "\\*$RE_ANCHOR_CAR+"; | ||
| 125 | |||||
| 126 | |||||
| 127 | 1 | 303µs | 7 | 251µs | my %REGEXES = ( # spent 237µs making 3 calls to YAML::PP::Lexer::CORE:regcomp, avg 79µs/call
# spent 14µs making 4 calls to YAML::PP::Lexer::CORE:qr, avg 4µs/call |
| 128 | ANCHOR => qr{($RE_ANCHOR)}, | ||||
| 129 | TAG => qr{($RE_TAG)}, | ||||
| 130 | ALIAS => qr{($RE_ALIAS)}, | ||||
| 131 | SINGLEQUOTED => qr{(?:''|[^'\r\n]+)*}, | ||||
| 132 | ); | ||||
| 133 | |||||
| 134 | # spent 295ms (175+119) within YAML::PP::Lexer::_fetch_next_line which was called 18360 times, avg 16µs/call:
# 13356 times (114ms+83.0ms) by YAML::PP::Lexer::fetch_next_tokens at line 185, avg 15µs/call
# 4998 times (61.2ms+36.0ms) by YAML::PP::Lexer::fetch_plain at line 412, avg 19µs/call
# 6 times (48µs+35µs) by YAML::PP::Lexer::fetch_block at line 562, avg 14µs/call | ||||
| 135 | 18360 | 3.09ms | my ($self) = @_; | ||
| 136 | 18360 | 11.2ms | 18360 | 7.85ms | my $next_line = $self->next_line; # spent 7.85ms making 18360 calls to YAML::PP::Lexer::next_line, avg 427ns/call |
| 137 | 18360 | 8.77ms | if (defined $next_line ) { | ||
| 138 | return $next_line; | ||||
| 139 | } | ||||
| 140 | |||||
| 141 | 13361 | 20.5ms | 26722 | 71.3ms | my $line = $self->reader->readline; # spent 64.3ms making 13361 calls to YAML::PP::Reader::File::readline, avg 5µs/call
# spent 7.02ms making 13361 calls to YAML::PP::Lexer::reader, avg 525ns/call |
| 142 | 13361 | 2.07ms | unless (defined $line) { | ||
| 143 | 1 | 1µs | 1 | 1µs | $self->set_next_line(undef); # spent 1µs making 1 call to YAML::PP::Lexer::set_next_line |
| 144 | 1 | 1µs | return; | ||
| 145 | } | ||||
| 146 | 13360 | 9.83ms | 13360 | 8.25ms | $self->set_block(1); # spent 8.25ms making 13360 calls to YAML::PP::Lexer::set_block, avg 618ns/call |
| 147 | 13360 | 7.38ms | 13360 | 6.09ms | $self->inc_line; # spent 6.09ms making 13360 calls to YAML::PP::Lexer::inc_line, avg 456ns/call |
| 148 | 13360 | 34.8ms | 13360 | 19.3ms | $line =~ m/\A( *)([^\r\n]*)([\r\n]|\z)/ or die "Unexpected"; # spent 19.3ms making 13360 calls to YAML::PP::Lexer::CORE:match, avg 1µs/call |
| 149 | 13360 | 18.2ms | $next_line = [ $1, $2, $3 ]; | ||
| 150 | 13360 | 7.83ms | 13360 | 6.27ms | $self->set_next_line($next_line); # spent 6.27ms making 13360 calls to YAML::PP::Lexer::set_next_line, avg 469ns/call |
| 151 | # $ESCAPE_CHAR from YAML.pm | ||||
| 152 | 13360 | 6.23ms | if ($line =~ tr/\x00-\x08\x0b-\x0c\x0e-\x1f//) { | ||
| 153 | $self->exception("Control characters are not allowed"); | ||||
| 154 | } | ||||
| 155 | |||||
| 156 | 13360 | 19.6ms | return $next_line; | ||
| 157 | } | ||||
| 158 | |||||
| 159 | 1 | 7µs | my %TOKEN_NAMES = ( | ||
| 160 | '"' => 'DOUBLEQUOTE', | ||||
| 161 | "'" => 'SINGLEQUOTE', | ||||
| 162 | '|' => 'LITERAL', | ||||
| 163 | '>' => 'FOLDED', | ||||
| 164 | '!' => 'TAG', | ||||
| 165 | '*' => 'ALIAS', | ||||
| 166 | '&' => 'ANCHOR', | ||||
| 167 | ':' => 'COLON', | ||||
| 168 | '-' => 'DASH', | ||||
| 169 | '?' => 'QUESTION', | ||||
| 170 | '[' => 'FLOWSEQ_START', | ||||
| 171 | ']' => 'FLOWSEQ_END', | ||||
| 172 | '{' => 'FLOWMAP_START', | ||||
| 173 | '}' => 'FLOWMAP_END', | ||||
| 174 | ',' => 'FLOW_COMMA', | ||||
| 175 | '---' => 'DOC_START', | ||||
| 176 | '...' => 'DOC_END', | ||||
| 177 | ); | ||||
| 178 | |||||
| 179 | |||||
| 180 | # spent 785ms (168+617) within YAML::PP::Lexer::fetch_next_tokens which was called 13356 times, avg 59µs/call:
# 13356 times (168ms+617ms) by YAML::PP::Parser::lex_next_tokens at line 179 of YAML/PP/Parser.pm, avg 59µs/call | ||||
| 181 | 13356 | 2.63ms | my ($self) = @_; | ||
| 182 | 13356 | 7.59ms | 13356 | 5.04ms | my $next = $self->next_tokens; # spent 5.04ms making 13356 calls to YAML::PP::Lexer::next_tokens, avg 378ns/call |
| 183 | 13356 | 2.39ms | return $next if @$next; | ||
| 184 | |||||
| 185 | 13356 | 10.6ms | 13356 | 197ms | my $next_line = $self->_fetch_next_line; # spent 197ms making 13356 calls to YAML::PP::Lexer::_fetch_next_line, avg 15µs/call |
| 186 | 13356 | 1.91ms | if (not $next_line) { | ||
| 187 | return []; | ||||
| 188 | } | ||||
| 189 | |||||
| 190 | 13355 | 3.81ms | my $spaces = $next_line->[0]; | ||
| 191 | 13355 | 3.49ms | my $yaml = \$next_line->[1]; | ||
| 192 | 13355 | 3.27ms | if (not length $$yaml) { | ||
| 193 | $self->_push_tokens([ EOL => join('', @$next_line), $self->line ]); | ||||
| 194 | $self->set_next_line(undef); | ||||
| 195 | return $next; | ||||
| 196 | } | ||||
| 197 | 13355 | 10.3ms | if (substr($$yaml, 0, 1) eq '#') { | ||
| 198 | $self->_push_tokens([ EOL => join('', @$next_line), $self->line ]); | ||||
| 199 | $self->set_next_line(undef); | ||||
| 200 | return $next; | ||||
| 201 | } | ||||
| 202 | 13355 | 1.93ms | if (not $spaces and substr($$yaml, 0, 1) eq "%") { | ||
| 203 | $self->_fetch_next_tokens_directive($yaml, $next_line->[2]); | ||||
| 204 | $self->set_context(0); | ||||
| 205 | $self->set_next_line(undef); | ||||
| 206 | return $next; | ||||
| 207 | } | ||||
| 208 | 13355 | 17.4ms | 13368 | 6.21ms | if (not $spaces and $$yaml =~ s/\A(---|\.\.\.)(?=$RE_WS|\z)//) { # spent 6.14ms making 13354 calls to YAML::PP::Lexer::flowcontext, avg 460ns/call
# spent 37µs making 6 calls to YAML::PP::Lexer::CORE:regcomp, avg 6µs/call
# spent 24µs making 1 call to YAML::PP::Lexer::_push_tokens
# spent 6µs making 6 calls to YAML::PP::Lexer::CORE:subst, avg 1µs/call
# spent 2µs making 1 call to YAML::PP::Lexer::line |
| 209 | $self->_push_tokens([ $TOKEN_NAMES{ $1 } => $1, $self->line ]); | ||||
| 210 | } | ||||
| 211 | elsif ($self->flowcontext and $$yaml =~ m/\A[ \t]+(#.*)?\z/) { | ||||
| 212 | $self->_push_tokens([ EOL => join('', @$next_line), $self->line ]); | ||||
| 213 | $self->set_next_line(undef); | ||||
| 214 | return $next; | ||||
| 215 | } | ||||
| 216 | else { | ||||
| 217 | 13354 | 19.9ms | 26708 | 148ms | $self->_push_tokens([ SPACE => $spaces, $self->line ]); # spent 143ms making 13354 calls to YAML::PP::Lexer::_push_tokens, avg 11µs/call
# spent 5.26ms making 13354 calls to YAML::PP::Lexer::line, avg 394ns/call |
| 218 | } | ||||
| 219 | |||||
| 220 | 13355 | 10.6ms | 13355 | 261ms | my $partial = $self->_fetch_next_tokens($next_line); # spent 261ms making 13355 calls to YAML::PP::Lexer::_fetch_next_tokens, avg 20µs/call |
| 221 | 13355 | 1.55ms | 1 | 1µs | unless ($partial) { # spent 1µs making 1 call to YAML::PP::Lexer::set_next_line |
| 222 | $self->set_next_line(undef); | ||||
| 223 | } | ||||
| 224 | 13355 | 19.5ms | return $next; | ||
| 225 | } | ||||
| 226 | |||||
| 227 | 1 | 1µs | my %ANCHOR_ALIAS_TAG = ( '&' => 1, '*' => 1, '!' => 1 ); | ||
| 228 | 1 | 1µs | my %BLOCK_SCALAR = ( '|' => 1, '>' => 1 ); | ||
| 229 | 1 | 1µs | my %COLON_DASH_QUESTION = ( ':' => 1, '-' => 1, '?' => 1 ); | ||
| 230 | 1 | 1µs | my %QUOTED = ( '"' => 1, "'" => 1 ); | ||
| 231 | 1 | 0s | my %FLOW = ( '{' => 1, '[' => 1, '}' => 1, ']' => 1, ',' => 1 ); | ||
| 232 | 1 | 0s | my %CONTEXT = ( '"' => 1, "'" => 1, '>' => 1, '|' => 1 ); | ||
| 233 | |||||
| 234 | 1 | 3µs | 1 | 1µs | my $RE_ESCAPES = qr{(?: # spent 1µs making 1 call to YAML::PP::Lexer::CORE:qr |
| 235 | \\([ \\\/_0abefnrtvLNP\t"]) | \\x([0-9a-fA-F]{2}) | ||||
| 236 | | \\u([A-Fa-f0-9]{4}) | \\U([A-Fa-f0-9]{4,8}) | ||||
| 237 | )}x; | ||||
| 238 | 1 | 8µs | my %CONTROL = ( | ||
| 239 | '\\' => '\\', '/' => '/', n => "\n", t => "\t", r => "\r", b => "\b", | ||||
| 240 | 'a' => "\a", 'b' => "\b", 'e' => "\e", 'f' => "\f", 'v' => "\x0b", "\t" => "\t", | ||||
| 241 | 'P' => "\x{2029}", L => "\x{2028}", 'N' => "\x85", | ||||
| 242 | '0' => "\0", '_' => "\xa0", ' ' => ' ', q/"/ => q/"/, | ||||
| 243 | ); | ||||
| 244 | |||||
| 245 | # spent 827ms (397+429) within YAML::PP::Lexer::_fetch_next_tokens which was called 27707 times, avg 30µs/call:
# 13720 times (276ms+266ms) by YAML::PP::Lexer::fetch_plain at line 397, avg 39µs/call
# 13355 times (110ms+151ms) by YAML::PP::Lexer::fetch_next_tokens at line 220, avg 20µs/call
# 632 times (11.6ms+12.2ms) by YAML::PP::Lexer::fetch_quoted at line 696, avg 38µs/call | ||||
| 246 | TRACE and warn __PACKAGE__.':'.__LINE__.": _fetch_next_tokens\n"; | ||||
| 247 | 27707 | 4.78ms | my ($self, $next_line) = @_; | ||
| 248 | |||||
| 249 | 27707 | 6.59ms | my $yaml = \$next_line->[1]; | ||
| 250 | 27707 | 5.04ms | my $eol = $next_line->[2]; | ||
| 251 | |||||
| 252 | 27707 | 2.68ms | my @tokens; | ||
| 253 | |||||
| 254 | 27707 | 3.19ms | while (1) { | ||
| 255 | 37662 | 5.43ms | unless (length $$yaml) { | ||
| 256 | 523 | 487µs | 523 | 208µs | push @tokens, ( EOL => $eol, $self->line ); # spent 208µs making 523 calls to YAML::PP::Lexer::line, avg 398ns/call |
| 257 | 523 | 412µs | 523 | 7.65ms | $self->_push_tokens(\@tokens); # spent 7.65ms making 523 calls to YAML::PP::Lexer::_push_tokens, avg 15µs/call |
| 258 | 523 | 1.03ms | return; | ||
| 259 | } | ||||
| 260 | 37139 | 13.1ms | my $first = substr($$yaml, 0, 1); | ||
| 261 | 37139 | 4.24ms | my $plain = 0; | ||
| 262 | |||||
| 263 | 37139 | 21.2ms | 37139 | 15.7ms | if ($self->context) { # spent 15.7ms making 37139 calls to YAML::PP::Lexer::context, avg 424ns/call |
| 264 | 88 | 238µs | 176 | 93µs | if ($$yaml =~ s/\A($RE_WS*)://) { # spent 52µs making 88 calls to YAML::PP::Lexer::CORE:regcomp, avg 591ns/call
# spent 41µs making 88 calls to YAML::PP::Lexer::CORE:subst, avg 466ns/call |
| 265 | push @tokens, ( WS => $1, $self->line ) if $1; | ||||
| 266 | push @tokens, ( COLON => ':', $self->line ); | ||||
| 267 | $self->set_context(0); | ||||
| 268 | next; | ||||
| 269 | } | ||||
| 270 | 88 | 258µs | 176 | 91µs | if ($$yaml =~ s/\A($RE_WS*(?: #.*))\z//) { # spent 65µs making 88 calls to YAML::PP::Lexer::CORE:regcomp, avg 739ns/call
# spent 26µs making 88 calls to YAML::PP::Lexer::CORE:subst, avg 295ns/call |
| 271 | push @tokens, ( EOL => $1 . $eol, $self->line ); | ||||
| 272 | $self->_push_tokens(\@tokens); | ||||
| 273 | return; | ||||
| 274 | } | ||||
| 275 | 88 | 78µs | 88 | 38µs | $self->set_context(0); # spent 38µs making 88 calls to YAML::PP::Lexer::set_context, avg 432ns/call |
| 276 | } | ||||
| 277 | 37139 | 24.2ms | if ($CONTEXT{ $first }) { | ||
| 278 | 2046 | 2.37ms | 2046 | 719µs | push @tokens, ( CONTEXT => $first, $self->line ); # spent 719µs making 2046 calls to YAML::PP::Lexer::line, avg 351ns/call |
| 279 | 2046 | 1.40ms | 2046 | 26.0ms | $self->_push_tokens(\@tokens); # spent 26.0ms making 2046 calls to YAML::PP::Lexer::_push_tokens, avg 13µs/call |
| 280 | 2046 | 3.80ms | return 1; | ||
| 281 | } | ||||
| 282 | elsif ($COLON_DASH_QUESTION{ $first }) { | ||||
| 283 | 13953 | 4.37ms | my $token_name = $TOKEN_NAMES{ $first }; | ||
| 284 | 13953 | 84.1ms | 27906 | 49.8ms | if ($$yaml =~ s/\A\Q$first\E($RE_WS+|\z)//) { # spent 29.8ms making 13953 calls to YAML::PP::Lexer::CORE:regcomp, avg 2µs/call
# spent 20.0ms making 13953 calls to YAML::PP::Lexer::CORE:subst, avg 1µs/call |
| 285 | 13953 | 4.49ms | my $after = $1; | ||
| 286 | 13953 | 17.1ms | 27877 | 13.5ms | if (not $self->flowcontext and not $self->block) { # spent 6.82ms making 13924 calls to YAML::PP::Lexer::block, avg 490ns/call
# spent 6.65ms making 13953 calls to YAML::PP::Lexer::flowcontext, avg 476ns/call |
| 287 | push @tokens, ERROR => $first . $after, $self->line; | ||||
| 288 | $self->_push_tokens(\@tokens); | ||||
| 289 | $self->exception("Tabs can not be used for indentation"); | ||||
| 290 | } | ||||
| 291 | 13953 | 4.20ms | if ($after =~ tr/\t//) { | ||
| 292 | $self->set_block(0); | ||||
| 293 | } | ||||
| 294 | 13953 | 3.22ms | my $token_name = $TOKEN_NAMES{ $first }; | ||
| 295 | 13953 | 12.2ms | 13953 | 4.75ms | push @tokens, ( $token_name => $first, $self->line ); # spent 4.75ms making 13953 calls to YAML::PP::Lexer::line, avg 340ns/call |
| 296 | 13953 | 3.01ms | if (not defined $1) { | ||
| 297 | push @tokens, ( EOL => $eol, $self->line ); | ||||
| 298 | $self->_push_tokens(\@tokens); | ||||
| 299 | return; | ||||
| 300 | } | ||||
| 301 | 13953 | 2.64ms | my $ws = $1; | ||
| 302 | 13953 | 29.1ms | 13953 | 13.5ms | if ($$yaml =~ s/\A(#.*|)\z//) { # spent 13.5ms making 13953 calls to YAML::PP::Lexer::CORE:subst, avg 969ns/call |
| 303 | 6420 | 9.71ms | 6420 | 2.93ms | push @tokens, ( EOL => $ws . $1 . $eol, $self->line ); # spent 2.93ms making 6420 calls to YAML::PP::Lexer::line, avg 457ns/call |
| 304 | 6420 | 3.80ms | 6420 | 79.1ms | $self->_push_tokens(\@tokens); # spent 79.1ms making 6420 calls to YAML::PP::Lexer::_push_tokens, avg 12µs/call |
| 305 | 6420 | 18.8ms | return; | ||
| 306 | } | ||||
| 307 | 7533 | 7.07ms | 7533 | 3.49ms | push @tokens, ( WS => $ws, $self->line ); # spent 3.49ms making 7533 calls to YAML::PP::Lexer::line, avg 463ns/call |
| 308 | 7533 | 6.55ms | next; | ||
| 309 | } | ||||
| 310 | elsif ($self->flowcontext and $$yaml =~ s/\A:(?=[,\{\}\[\]])//) { | ||||
| 311 | push @tokens, ( $token_name => $first, $self->line ); | ||||
| 312 | next; | ||||
| 313 | } | ||||
| 314 | $plain = 1; | ||||
| 315 | } | ||||
| 316 | elsif ($ANCHOR_ALIAS_TAG{ $first }) { | ||||
| 317 | my $token_name = $TOKEN_NAMES{ $first }; | ||||
| 318 | my $REGEX = $REGEXES{ $token_name }; | ||||
| 319 | if ($$yaml =~ s/\A$REGEX//) { | ||||
| 320 | push @tokens, ( $token_name => $1, $self->line ); | ||||
| 321 | } | ||||
| 322 | else { | ||||
| 323 | push @tokens, ( "Invalid $token_name" => $$yaml, $self->line ); | ||||
| 324 | $self->_push_tokens(\@tokens); | ||||
| 325 | return; | ||||
| 326 | } | ||||
| 327 | } | ||||
| 328 | elsif ($first eq ' ' or $first eq "\t") { | ||||
| 329 | 666 | 2.75ms | 1332 | 1.14ms | if ($$yaml =~ s/\A($RE_WS+)//) { # spent 753µs making 666 calls to YAML::PP::Lexer::CORE:subst, avg 1µs/call
# spent 386µs making 666 calls to YAML::PP::Lexer::CORE:regcomp, avg 580ns/call |
| 330 | 666 | 293µs | my $ws = $1; | ||
| 331 | 666 | 1.28ms | 666 | 595µs | if ($$yaml =~ s/\A((?:#.*)?\z)//) { # spent 595µs making 666 calls to YAML::PP::Lexer::CORE:subst, avg 893ns/call |
| 332 | push @tokens, ( EOL => $ws . $1 . $eol, $self->line ); | ||||
| 333 | $self->_push_tokens(\@tokens); | ||||
| 334 | return; | ||||
| 335 | } | ||||
| 336 | 666 | 658µs | 666 | 302µs | push @tokens, ( WS => $ws, $self->line ); # spent 302µs making 666 calls to YAML::PP::Lexer::line, avg 453ns/call |
| 337 | } | ||||
| 338 | } | ||||
| 339 | elsif ($FLOW{ $first }) { | ||||
| 340 | 1756 | 2.05ms | 1756 | 561µs | push @tokens, ( $TOKEN_NAMES{ $first } => $first, $self->line ); # spent 561µs making 1756 calls to YAML::PP::Lexer::line, avg 319ns/call |
| 341 | 1756 | 1.37ms | substr($$yaml, 0, 1, ''); | ||
| 342 | 1756 | 1.04ms | 1756 | 645µs | my $flowcontext = $self->flowcontext; # spent 645µs making 1756 calls to YAML::PP::Lexer::flowcontext, avg 367ns/call |
| 343 | 1756 | 1.53ms | 1090 | 741µs | if ($first eq '{' or $first eq '[') { # spent 741µs making 1090 calls to YAML::PP::Lexer::set_flowcontext, avg 680ns/call |
| 344 | $self->set_flowcontext(++$flowcontext); | ||||
| 345 | } | ||||
| 346 | elsif ($first eq '}' or $first eq ']') { | ||||
| 347 | $self->set_flowcontext(--$flowcontext); | ||||
| 348 | } | ||||
| 349 | } | ||||
| 350 | else { | ||||
| 351 | 18718 | 2.50ms | $plain = 1; | ||
| 352 | } | ||||
| 353 | |||||
| 354 | 21140 | 3.04ms | if ($plain) { | ||
| 355 | 18718 | 13.8ms | 18718 | 6.89ms | push @tokens, ( CONTEXT => '', $self->line ); # spent 6.89ms making 18718 calls to YAML::PP::Lexer::line, avg 368ns/call |
| 356 | 18718 | 10.9ms | 18718 | 201ms | $self->_push_tokens(\@tokens); # spent 201ms making 18718 calls to YAML::PP::Lexer::_push_tokens, avg 11µs/call |
| 357 | 18718 | 31.9ms | return 1; | ||
| 358 | } | ||||
| 359 | |||||
| 360 | } | ||||
| 361 | |||||
| 362 | return; | ||||
| 363 | } | ||||
| 364 | |||||
| 365 | # spent 1.49s (384ms+1.11) within YAML::PP::Lexer::fetch_plain which was called 18718 times, avg 80µs/call:
# 18718 times (384ms+1.11s) by YAML::PP::Parser::parse_tokens at line 381 of YAML/PP/Parser.pm, avg 80µs/call | ||||
| 366 | 18718 | 5.11ms | my ($self, $indent, $context) = @_; | ||
| 367 | 18718 | 12.5ms | 18718 | 8.69ms | my $next_line = $self->next_line; # spent 8.69ms making 18718 calls to YAML::PP::Lexer::next_line, avg 464ns/call |
| 368 | 18718 | 4.46ms | my $yaml = \$next_line->[1]; | ||
| 369 | 18718 | 3.41ms | my $eol = $next_line->[2]; | ||
| 370 | 18718 | 3.53ms | my $REGEX = $RE_PLAIN_WORDS; | ||
| 371 | 18718 | 9.21ms | 18718 | 6.25ms | if ($self->flowcontext) { # spent 6.25ms making 18718 calls to YAML::PP::Lexer::flowcontext, avg 334ns/call |
| 372 | $REGEX = $RE_PLAIN_WORDS_FLOW; | ||||
| 373 | } | ||||
| 374 | |||||
| 375 | 18718 | 2.06ms | my @tokens; | ||
| 376 | 18718 | 262ms | 37436 | 188ms | unless ($$yaml =~ s/\A($REGEX)//) { # spent 105ms making 18718 calls to YAML::PP::Lexer::CORE:regcomp, avg 6µs/call
# spent 82.7ms making 18718 calls to YAML::PP::Lexer::CORE:subst, avg 4µs/call |
| 377 | $self->_push_tokens(\@tokens); | ||||
| 378 | $self->exception("Invalid plain scalar"); | ||||
| 379 | } | ||||
| 380 | 18718 | 9.46ms | my $plain = $1; | ||
| 381 | 18718 | 18.1ms | 18718 | 9.18ms | push @tokens, ( PLAIN => $plain, $self->line ); # spent 9.18ms making 18718 calls to YAML::PP::Lexer::line, avg 490ns/call |
| 382 | |||||
| 383 | 18718 | 73.2ms | 37436 | 33.0ms | if ($$yaml =~ s/\A(?:($RE_WS+#.*)|($RE_WS*))\z//) { # spent 19.0ms making 18718 calls to YAML::PP::Lexer::CORE:subst, avg 1µs/call
# spent 14.0ms making 18718 calls to YAML::PP::Lexer::CORE:regcomp, avg 746ns/call |
| 384 | 4998 | 2.19ms | if (defined $1) { | ||
| 385 | push @tokens, ( EOL => $1 . $eol, $self->line ); | ||||
| 386 | $self->_push_tokens(\@tokens); | ||||
| 387 | $self->set_next_line(undef); | ||||
| 388 | return; | ||||
| 389 | } | ||||
| 390 | else { | ||||
| 391 | 4998 | 6.44ms | 4998 | 2.12ms | push @tokens, ( EOL => $2. $eol, $self->line ); # spent 2.12ms making 4998 calls to YAML::PP::Lexer::line, avg 424ns/call |
| 392 | 4998 | 4.00ms | 4998 | 2.97ms | $self->set_next_line(undef); # spent 2.97ms making 4998 calls to YAML::PP::Lexer::set_next_line, avg 594ns/call |
| 393 | } | ||||
| 394 | } | ||||
| 395 | else { | ||||
| 396 | 13720 | 9.04ms | 13720 | 142ms | $self->_push_tokens(\@tokens); # spent 142ms making 13720 calls to YAML::PP::Lexer::_push_tokens, avg 10µs/call |
| 397 | 13720 | 18.7ms | 13720 | 542ms | my $partial = $self->_fetch_next_tokens($next_line); # spent 542ms making 13720 calls to YAML::PP::Lexer::_fetch_next_tokens, avg 39µs/call |
| 398 | 13720 | 5.45ms | 6344 | 3.56ms | if (not $partial) { # spent 3.56ms making 6344 calls to YAML::PP::Lexer::set_next_line, avg 561ns/call |
| 399 | $self->set_next_line(undef); | ||||
| 400 | } | ||||
| 401 | 13720 | 32.4ms | return; | ||
| 402 | } | ||||
| 403 | |||||
| 404 | 4998 | 1.14ms | my $RE2 = $RE_PLAIN_WORDS2; | ||
| 405 | 4998 | 2.96ms | 4998 | 1.61ms | if ($self->flowcontext) { # spent 1.61ms making 4998 calls to YAML::PP::Lexer::flowcontext, avg 322ns/call |
| 406 | $RE2 = $RE_PLAIN_WORDS_FLOW2; | ||||
| 407 | } | ||||
| 408 | 4998 | 599µs | my $fetch_next = 0; | ||
| 409 | 4998 | 2.31ms | my @lines = ($plain); | ||
| 410 | 4998 | 580µs | my @next; | ||
| 411 | 4998 | 725µs | LOOP: while (1) { | ||
| 412 | 4998 | 6.74ms | 4998 | 97.2ms | $next_line = $self->_fetch_next_line; # spent 97.2ms making 4998 calls to YAML::PP::Lexer::_fetch_next_line, avg 19µs/call |
| 413 | 4998 | 869µs | if (not $next_line) { | ||
| 414 | last LOOP; | ||||
| 415 | } | ||||
| 416 | 4998 | 1.39ms | my $spaces = $next_line->[0]; | ||
| 417 | 4998 | 1.35ms | my $yaml = \$next_line->[1]; | ||
| 418 | 4998 | 1.12ms | my $eol = $next_line->[2]; | ||
| 419 | |||||
| 420 | 4998 | 1.17ms | if (not length $$yaml) { | ||
| 421 | push @tokens, ( EOL => $spaces . $eol, $self->line ); | ||||
| 422 | $self->set_next_line(undef); | ||||
| 423 | push @lines, ''; | ||||
| 424 | next LOOP; | ||||
| 425 | } | ||||
| 426 | |||||
| 427 | 4998 | 1.13ms | 6 | 20µs | if (not $spaces and $$yaml =~ s/\A(---|\.\.\.)(?=$RE_WS|\z)//) { # spent 17µs making 3 calls to YAML::PP::Lexer::CORE:regcomp, avg 6µs/call
# spent 3µs making 3 calls to YAML::PP::Lexer::CORE:subst, avg 1µs/call |
| 428 | push @next, $TOKEN_NAMES{ $1 } => $1, $self->line; | ||||
| 429 | $fetch_next = 1; | ||||
| 430 | last LOOP; | ||||
| 431 | } | ||||
| 432 | 4998 | 2.91ms | if ((length $spaces) < $indent) { | ||
| 433 | 4998 | 3.61ms | last LOOP; | ||
| 434 | } | ||||
| 435 | |||||
| 436 | my $ws = ''; | ||||
| 437 | if ($$yaml =~ s/\A($RE_WS+)//) { | ||||
| 438 | $ws = $1; | ||||
| 439 | } | ||||
| 440 | if (not length $$yaml) { | ||||
| 441 | push @tokens, ( EOL => $spaces . $ws . $eol, $self->line ); | ||||
| 442 | $self->set_next_line(undef); | ||||
| 443 | push @lines, ''; | ||||
| 444 | next LOOP; | ||||
| 445 | } | ||||
| 446 | if ($$yaml =~ s/\A(#.*)\z//) { | ||||
| 447 | push @tokens, ( EOL => $spaces . $ws . $1 . $eol, $self->line ); | ||||
| 448 | $self->set_next_line(undef); | ||||
| 449 | last LOOP; | ||||
| 450 | } | ||||
| 451 | |||||
| 452 | if ($$yaml =~ s/\A($RE2)//) { | ||||
| 453 | push @tokens, INDENT => $spaces, $self->line; | ||||
| 454 | push @tokens, WS => $ws, $self->line; | ||||
| 455 | push @tokens, PLAIN => $1, $self->line; | ||||
| 456 | push @lines, $1; | ||||
| 457 | my $ws = ''; | ||||
| 458 | if ($$yaml =~ s/\A($RE_WS+)//) { | ||||
| 459 | $ws = $1; | ||||
| 460 | } | ||||
| 461 | if (not length $$yaml) { | ||||
| 462 | push @tokens, EOL => $ws . $eol, $self->line; | ||||
| 463 | $self->set_next_line(undef); | ||||
| 464 | next LOOP; | ||||
| 465 | } | ||||
| 466 | |||||
| 467 | if ($$yaml =~ s/\A(#.*)\z//) { | ||||
| 468 | push @tokens, EOL => $ws . $1 . $eol, $self->line; | ||||
| 469 | $self->set_next_line(undef); | ||||
| 470 | last LOOP; | ||||
| 471 | } | ||||
| 472 | else { | ||||
| 473 | push @tokens, WS => $ws, $self->line if $ws; | ||||
| 474 | $fetch_next = 1; | ||||
| 475 | } | ||||
| 476 | } | ||||
| 477 | else { | ||||
| 478 | push @tokens, SPACE => $spaces, $self->line; | ||||
| 479 | push @tokens, WS => $ws, $self->line; | ||||
| 480 | if ($self->flowcontext) { | ||||
| 481 | $fetch_next = 1; | ||||
| 482 | } | ||||
| 483 | else { | ||||
| 484 | push @tokens, ERROR => $$yaml, $self->line; | ||||
| 485 | } | ||||
| 486 | } | ||||
| 487 | |||||
| 488 | last LOOP; | ||||
| 489 | |||||
| 490 | } | ||||
| 491 | # remove empty lines at the end | ||||
| 492 | 4998 | 2.64ms | while (@lines > 1 and $lines[-1] eq '') { | ||
| 493 | pop @lines; | ||||
| 494 | } | ||||
| 495 | 4998 | 4.58ms | if (@lines > 1) { | ||
| 496 | my $value = YAML::PP::Render->render_multi_val(\@lines); | ||||
| 497 | my @eol; | ||||
| 498 | if ($tokens[-3] eq 'EOL') { | ||||
| 499 | @eol = splice @tokens, -3; | ||||
| 500 | } | ||||
| 501 | $self->push_subtokens( { name => 'PLAIN_MULTI', value => $value }, \@tokens); | ||||
| 502 | $self->_push_tokens([ @eol, @next ]); | ||||
| 503 | } | ||||
| 504 | else { | ||||
| 505 | 4998 | 7.29ms | 4998 | 69.6ms | $self->_push_tokens([ @tokens, @next ]); # spent 69.6ms making 4998 calls to YAML::PP::Lexer::_push_tokens, avg 14µs/call |
| 506 | } | ||||
| 507 | 4998 | 2.71ms | @tokens = (); | ||
| 508 | 4998 | 897µs | if ($fetch_next) { | ||
| 509 | my $partial = $self->_fetch_next_tokens($next_line); | ||||
| 510 | if (not $partial) { | ||||
| 511 | $self->set_next_line(undef); | ||||
| 512 | } | ||||
| 513 | } | ||||
| 514 | 4998 | 12.2ms | return; | ||
| 515 | } | ||||
| 516 | |||||
| 517 | # spent 272µs (94+178) within YAML::PP::Lexer::fetch_block which was called:
# once (94µs+178µs) by YAML::PP::Parser::parse_tokens at line 381 of YAML/PP/Parser.pm | ||||
| 518 | 1 | 1µs | my ($self, $indent, $context) = @_; | ||
| 519 | 1 | 2µs | 1 | 1µs | my $next_line = $self->next_line; # spent 1µs making 1 call to YAML::PP::Lexer::next_line |
| 520 | 1 | 0s | my $yaml = \$next_line->[1]; | ||
| 521 | 1 | 0s | my $eol = $next_line->[2]; | ||
| 522 | |||||
| 523 | 1 | 0s | my @tokens; | ||
| 524 | 1 | 1µs | my $token_name = $TOKEN_NAMES{ $context }; | ||
| 525 | 1 | 11µs | 2 | 6µs | $$yaml =~ s/\A\Q$context\E// or die "Unexpected"; # spent 5µs making 1 call to YAML::PP::Lexer::CORE:regcomp
# spent 1µs making 1 call to YAML::PP::Lexer::CORE:subst |
| 526 | 1 | 1µs | 1 | 0s | push @tokens, ( $token_name => $context, $self->line ); # spent 0s making 1 call to YAML::PP::Lexer::line |
| 527 | 1 | 0s | my $current_indent = $indent; | ||
| 528 | 1 | 0s | my $started = 0; | ||
| 529 | 1 | 0s | my $set_indent = 0; | ||
| 530 | 1 | 1µs | my $chomp = ''; | ||
| 531 | 1 | 4µs | 2 | 3µs | if ($$yaml =~ s/\A([1-9])([+-]?)//) { # spent 3µs making 2 calls to YAML::PP::Lexer::CORE:subst, avg 2µs/call |
| 532 | push @tokens, ( BLOCK_SCALAR_INDENT => $1, $self->line ); | ||||
| 533 | $set_indent = $1; | ||||
| 534 | $chomp = $2 if $2; | ||||
| 535 | push @tokens, ( BLOCK_SCALAR_CHOMP => $2, $self->line ) if $2; | ||||
| 536 | } | ||||
| 537 | elsif ($$yaml =~ s/\A([+-])([1-9])?//) { | ||||
| 538 | 1 | 1µs | 1 | 0s | push @tokens, ( BLOCK_SCALAR_CHOMP => $1, $self->line ); # spent 0s making 1 call to YAML::PP::Lexer::line |
| 539 | 1 | 1µs | $chomp = $1; | ||
| 540 | 1 | 0s | push @tokens, ( BLOCK_SCALAR_INDENT => $2, $self->line ) if $2; | ||
| 541 | 1 | 1µs | $set_indent = $2 if $2; | ||
| 542 | } | ||||
| 543 | 1 | 1µs | if ($set_indent) { | ||
| 544 | $started = 1; | ||||
| 545 | $indent-- if $indent > 0; | ||||
| 546 | $current_indent = $indent + $set_indent; | ||||
| 547 | } | ||||
| 548 | 1 | 2µs | 1 | 1µs | if (not length $$yaml) { # spent 1µs making 1 call to YAML::PP::Lexer::line |
| 549 | push @tokens, ( EOL => $eol, $self->line ); | ||||
| 550 | } | ||||
| 551 | elsif ($$yaml =~ s/\A($RE_WS*(?:$RE_WS#.*|))\z//) { | ||||
| 552 | push @tokens, ( EOL => $1 . $eol, $self->line ); | ||||
| 553 | } | ||||
| 554 | else { | ||||
| 555 | $self->_push_tokens(\@tokens); | ||||
| 556 | $self->exception("Invalid block scalar"); | ||||
| 557 | } | ||||
| 558 | |||||
| 559 | 1 | 0s | my @lines; | ||
| 560 | 1 | 1µs | while (1) { | ||
| 561 | 6 | 2µs | 6 | 1µs | $self->set_next_line(undef); # spent 1µs making 6 calls to YAML::PP::Lexer::set_next_line, avg 167ns/call |
| 562 | 6 | 3µs | 6 | 83µs | $next_line = $self->_fetch_next_line; # spent 83µs making 6 calls to YAML::PP::Lexer::_fetch_next_line, avg 14µs/call |
| 563 | 6 | 1µs | if (not $next_line) { | ||
| 564 | last; | ||||
| 565 | } | ||||
| 566 | 6 | 2µs | my $spaces = $next_line->[0]; | ||
| 567 | 6 | 0s | my $content = $next_line->[1]; | ||
| 568 | 6 | 1µs | my $eol = $next_line->[2]; | ||
| 569 | 6 | 1µs | if (not $spaces and $content =~ m/\A(---|\.\.\.)(?=$RE_WS|\z)/) { | ||
| 570 | last; | ||||
| 571 | } | ||||
| 572 | 6 | 2µs | if ((length $spaces) < $current_indent) { | ||
| 573 | 1 | 0s | if (length $content) { | ||
| 574 | 1 | 3µs | 1 | 1µs | if ($content =~ m/\A\t/) { # spent 1µs making 1 call to YAML::PP::Lexer::CORE:match |
| 575 | $self->_push_tokens(\@tokens); | ||||
| 576 | $self->exception("Invalid block scalar"); | ||||
| 577 | } | ||||
| 578 | 1 | 0s | last; | ||
| 579 | } | ||||
| 580 | else { | ||||
| 581 | push @lines, ''; | ||||
| 582 | push @tokens, ( EOL => $spaces . $eol, $self->line ); | ||||
| 583 | next; | ||||
| 584 | } | ||||
| 585 | } | ||||
| 586 | 5 | 1µs | if ((length $spaces) > $current_indent) { | ||
| 587 | 1 | 1µs | if ($started) { | ||
| 588 | ($spaces, my $more_spaces) = unpack "a${current_indent}a*", $spaces; | ||||
| 589 | $content = $more_spaces . $content; | ||||
| 590 | } | ||||
| 591 | } | ||||
| 592 | 5 | 0s | unless (length $content) { | ||
| 593 | push @lines, ''; | ||||
| 594 | push @tokens, ( INDENT => $spaces, $self->line, EOL => $eol, $self->line ); | ||||
| 595 | unless ($started) { | ||||
| 596 | $current_indent = length $spaces; | ||||
| 597 | } | ||||
| 598 | next; | ||||
| 599 | } | ||||
| 600 | 5 | 0s | unless ($started) { | ||
| 601 | 1 | 0s | $started = 1; | ||
| 602 | 1 | 1µs | $current_indent = length $spaces; | ||
| 603 | } | ||||
| 604 | 5 | 1µs | push @lines, $content; | ||
| 605 | 5 | 17µs | 15 | 4µs | push @tokens, ( # spent 4µs making 15 calls to YAML::PP::Lexer::line, avg 267ns/call |
| 606 | INDENT => $spaces, $self->line, | ||||
| 607 | BLOCK_SCALAR_CONTENT => $content, $self->line, | ||||
| 608 | EOL => $eol, $self->line, | ||||
| 609 | ); | ||||
| 610 | } | ||||
| 611 | 1 | 8µs | 1 | 16µs | my $value = YAML::PP::Render->render_block_scalar($context, $chomp, \@lines); # spent 16µs making 1 call to YAML::PP::Render::render_block_scalar |
| 612 | 1 | 1µs | my @eol = splice @tokens, -3; | ||
| 613 | 1 | 1µs | 1 | 54µs | $self->push_subtokens( { name => 'BLOCK_SCALAR', value => $value }, \@tokens ); # spent 54µs making 1 call to YAML::PP::Lexer::push_subtokens |
| 614 | 1 | 2µs | 1 | 8µs | $self->_push_tokens([ @eol ]); # spent 8µs making 1 call to YAML::PP::Lexer::_push_tokens |
| 615 | 1 | 5µs | return 0; | ||
| 616 | } | ||||
| 617 | |||||
| 618 | # spent 198ms (50.4+147) within YAML::PP::Lexer::fetch_quoted which was called 2045 times, avg 97µs/call:
# 2045 times (50.4ms+147ms) by YAML::PP::Parser::parse_tokens at line 381 of YAML/PP/Parser.pm, avg 97µs/call | ||||
| 619 | 2045 | 856µs | my ($self, $indent, $context) = @_; | ||
| 620 | 2045 | 1.75ms | 2045 | 1.02ms | my $next_line = $self->next_line; # spent 1.02ms making 2045 calls to YAML::PP::Lexer::next_line, avg 499ns/call |
| 621 | 2045 | 845µs | my $yaml = \$next_line->[1]; | ||
| 622 | 2045 | 678µs | my $spaces = $next_line->[0]; | ||
| 623 | |||||
| 624 | 2045 | 597µs | my $token_name = $TOKEN_NAMES{ $context }; | ||
| 625 | 2045 | 10.6ms | 4090 | 5.12ms | $$yaml =~ s/\A\Q$context// or die "Unexpected";; # spent 3.99ms making 2045 calls to YAML::PP::Lexer::CORE:subst, avg 2µs/call
# spent 1.13ms making 2045 calls to YAML::PP::Lexer::CORE:regcomp, avg 551ns/call |
| 626 | 2045 | 3.06ms | 2045 | 903µs | my @tokens = ( $token_name => $context, $self->line ); # spent 903µs making 2045 calls to YAML::PP::Lexer::line, avg 442ns/call |
| 627 | |||||
| 628 | 2045 | 484µs | my $start = 1; | ||
| 629 | 2045 | 351µs | my @values; | ||
| 630 | 2045 | 318µs | while (1) { | ||
| 631 | |||||
| 632 | 2045 | 305µs | unless ($start) { | ||
| 633 | $next_line = $self->_fetch_next_line or do { | ||||
| 634 | for (my $i = 0; $i < @tokens; $i+= 3) { | ||||
| 635 | my $token = $tokens[ $i + 1 ]; | ||||
| 636 | if (ref $token) { | ||||
| 637 | $tokens[ $i + 1 ] = $token->{orig}; | ||||
| 638 | } | ||||
| 639 | } | ||||
| 640 | $self->_push_tokens(\@tokens); | ||||
| 641 | $self->exception("Missing closing quote <$context> at EOF"); | ||||
| 642 | }; | ||||
| 643 | $start = 0; | ||||
| 644 | $spaces = $next_line->[0]; | ||||
| 645 | $yaml = \$next_line->[1]; | ||||
| 646 | |||||
| 647 | if (not length $$yaml) { | ||||
| 648 | push @tokens, ( EOL => $spaces . $next_line->[2], $self->line ); | ||||
| 649 | $self->set_next_line(undef); | ||||
| 650 | push @values, { value => '', orig => '' }; | ||||
| 651 | next; | ||||
| 652 | } | ||||
| 653 | elsif (not $spaces and $$yaml =~ m/\A(---|\.\.\.)(?=$RE_WS|\z)/) { | ||||
| 654 | for (my $i = 0; $i < @tokens; $i+= 3) { | ||||
| 655 | my $token = $tokens[ $i + 1 ]; | ||||
| 656 | if (ref $token) { | ||||
| 657 | $tokens[ $i + 1 ] = $token->{orig}; | ||||
| 658 | } | ||||
| 659 | } | ||||
| 660 | $self->_push_tokens(\@tokens); | ||||
| 661 | $self->exception("Missing closing quote <$context> or invalid document marker"); | ||||
| 662 | } | ||||
| 663 | elsif ((length $spaces) < $indent) { | ||||
| 664 | for (my $i = 0; $i < @tokens; $i+= 3) { | ||||
| 665 | my $token = $tokens[ $i + 1 ]; | ||||
| 666 | if (ref $token) { | ||||
| 667 | $tokens[ $i + 1 ] = $token->{orig}; | ||||
| 668 | } | ||||
| 669 | } | ||||
| 670 | $self->_push_tokens(\@tokens); | ||||
| 671 | $self->exception("Wrong indendation or missing closing quote <$context>"); | ||||
| 672 | } | ||||
| 673 | |||||
| 674 | if ($$yaml =~ s/\A($RE_WS+)//) { | ||||
| 675 | $spaces .= $1; | ||||
| 676 | } | ||||
| 677 | push @tokens, ( WS => $spaces, $self->line ); | ||||
| 678 | } | ||||
| 679 | |||||
| 680 | 2045 | 3.51ms | 2045 | 47.2ms | my $v = $self->_read_quoted_tokens($start, $context, $yaml, \@tokens); # spent 47.2ms making 2045 calls to YAML::PP::Lexer::_read_quoted_tokens, avg 23µs/call |
| 681 | 2045 | 470µs | push @values, $v; | ||
| 682 | 2045 | 983µs | if ($tokens[-3] eq $token_name) { | ||
| 683 | 2045 | 5.07ms | 2045 | 52.5ms | if ($start) { # spent 52.5ms making 2045 calls to YAML::PP::Lexer::push_subtokens, avg 26µs/call |
| 684 | $self->push_subtokens( | ||||
| 685 | { name => 'QUOTED', value => $v->{value} }, \@tokens | ||||
| 686 | ); | ||||
| 687 | } | ||||
| 688 | else { | ||||
| 689 | my $value = YAML::PP::Render->render_quoted($context, \@values); | ||||
| 690 | $self->push_subtokens( | ||||
| 691 | { name => 'QUOTED_MULTILINE', value => $value }, \@tokens | ||||
| 692 | ); | ||||
| 693 | } | ||||
| 694 | 2045 | 1.61ms | 2133 | 922µs | $self->set_context(1) if $self->flowcontext; # spent 875µs making 2045 calls to YAML::PP::Lexer::flowcontext, avg 428ns/call
# spent 47µs making 88 calls to YAML::PP::Lexer::set_context, avg 534ns/call |
| 695 | 2045 | 1.06ms | if (length $$yaml) { | ||
| 696 | 632 | 595µs | 632 | 23.8ms | my $partial = $self->_fetch_next_tokens($next_line); # spent 23.8ms making 632 calls to YAML::PP::Lexer::_fetch_next_tokens, avg 38µs/call |
| 697 | 632 | 586µs | 598 | 330µs | if (not $partial) { # spent 330µs making 598 calls to YAML::PP::Lexer::set_next_line, avg 552ns/call |
| 698 | $self->set_next_line(undef); | ||||
| 699 | } | ||||
| 700 | 632 | 2.70ms | return 0; | ||
| 701 | } | ||||
| 702 | else { | ||||
| 703 | 1413 | 1.01ms | @tokens = (); | ||
| 704 | 1413 | 1.71ms | 1413 | 564µs | push @tokens, ( EOL => $next_line->[2], $self->line ); # spent 564µs making 1413 calls to YAML::PP::Lexer::line, avg 399ns/call |
| 705 | 1413 | 985µs | 1413 | 14.1ms | $self->_push_tokens(\@tokens); # spent 14.1ms making 1413 calls to YAML::PP::Lexer::_push_tokens, avg 10µs/call |
| 706 | 1413 | 945µs | 1413 | 765µs | $self->set_next_line(undef); # spent 765µs making 1413 calls to YAML::PP::Lexer::set_next_line, avg 541ns/call |
| 707 | 1413 | 5.28ms | return; | ||
| 708 | } | ||||
| 709 | } | ||||
| 710 | $tokens[-2] .= $next_line->[2]; | ||||
| 711 | $self->set_next_line(undef); | ||||
| 712 | $start = 0; | ||||
| 713 | } | ||||
| 714 | } | ||||
| 715 | |||||
| 716 | # spent 47.2ms (35.4+11.8) within YAML::PP::Lexer::_read_quoted_tokens which was called 2045 times, avg 23µs/call:
# 2045 times (35.4ms+11.8ms) by YAML::PP::Lexer::fetch_quoted at line 680, avg 23µs/call | ||||
| 717 | 2045 | 959µs | my ($self, $start, $first, $yaml, $tokens) = @_; | ||
| 718 | 2045 | 712µs | my $quoted = ''; | ||
| 719 | 2045 | 610µs | my $decoded = ''; | ||
| 720 | 2045 | 674µs | my $token_name = $TOKEN_NAMES{ $first }; | ||
| 721 | 2045 | 447µs | my $eol = ''; | ||
| 722 | 2045 | 1.08ms | if ($first eq "'") { | ||
| 723 | 2045 | 832µs | my $regex = $REGEXES{SINGLEQUOTED}; | ||
| 724 | 2045 | 12.0ms | 4090 | 5.98ms | if ($$yaml =~ s/\A($regex)//) { # spent 4.16ms making 2045 calls to YAML::PP::Lexer::CORE:subst, avg 2µs/call
# spent 1.82ms making 2045 calls to YAML::PP::Lexer::CORE:regcomp, avg 890ns/call |
| 725 | 2045 | 2.12ms | $quoted .= $1; | ||
| 726 | 2045 | 837µs | $decoded .= $1; | ||
| 727 | 2045 | 3.41ms | 2045 | 1.29ms | $decoded =~ s/''/'/g; # spent 1.29ms making 2045 calls to YAML::PP::Lexer::CORE:subst, avg 632ns/call |
| 728 | } | ||||
| 729 | 2045 | 1.25ms | unless (length $$yaml) { | ||
| 730 | if ($quoted =~ s/($RE_WS+)\z//) { | ||||
| 731 | $eol = $1; | ||||
| 732 | $decoded =~ s/($eol)\z//; | ||||
| 733 | } | ||||
| 734 | } | ||||
| 735 | } | ||||
| 736 | else { | ||||
| 737 | ($quoted, $decoded, $eol) = $self->_read_doublequoted($yaml); | ||||
| 738 | } | ||||
| 739 | 2045 | 2.79ms | my $value = { value => $decoded, orig => $quoted }; | ||
| 740 | |||||
| 741 | 2045 | 7.02ms | 4090 | 2.88ms | if ($$yaml =~ s/\A$first//) { # spent 2.03ms making 2045 calls to YAML::PP::Lexer::CORE:subst, avg 994ns/call
# spent 851µs making 2045 calls to YAML::PP::Lexer::CORE:regcomp, avg 416ns/call |
| 742 | 2045 | 2.94ms | 2045 | 1.01ms | if ($start) { # spent 1.01ms making 2045 calls to YAML::PP::Lexer::line, avg 494ns/call |
| 743 | push @$tokens, ( $token_name . 'D' => $value, $self->line ); | ||||
| 744 | } | ||||
| 745 | else { | ||||
| 746 | push @$tokens, ( $token_name . 'D_LINE' => $value, $self->line ); | ||||
| 747 | } | ||||
| 748 | 2045 | 1.92ms | 2045 | 663µs | push @$tokens, ( $token_name => $first, $self->line ); # spent 663µs making 2045 calls to YAML::PP::Lexer::line, avg 324ns/call |
| 749 | 2045 | 4.09ms | return $value; | ||
| 750 | } | ||||
| 751 | if (length $$yaml) { | ||||
| 752 | push @$tokens, ( $token_name . 'D' => $value->{orig}, $self->line ); | ||||
| 753 | $self->_push_tokens($tokens); | ||||
| 754 | $self->exception("Invalid quoted <$first> string"); | ||||
| 755 | } | ||||
| 756 | |||||
| 757 | push @$tokens, ( $token_name . 'D_LINE' => $value, $self->line ); | ||||
| 758 | push @$tokens, ( EOL => $eol, $self->line ); | ||||
| 759 | |||||
| 760 | return $value; | ||||
| 761 | } | ||||
| 762 | |||||
| 763 | sub _read_doublequoted { | ||||
| 764 | my ($self, $yaml) = @_; | ||||
| 765 | my $quoted = ''; | ||||
| 766 | my $decoded = ''; | ||||
| 767 | my $eol = ''; | ||||
| 768 | while (1) { | ||||
| 769 | my $last = 1; | ||||
| 770 | if ($$yaml =~ s/\A([^"\\ \t]+)//) { | ||||
| 771 | $quoted .= $1; | ||||
| 772 | $decoded .= $1; | ||||
| 773 | $last = 0; | ||||
| 774 | } | ||||
| 775 | if ($$yaml =~ s/\A($RE_ESCAPES)//) { | ||||
| 776 | $quoted .= $1; | ||||
| 777 | my $dec = defined $2 ? $CONTROL{ $2 } | ||||
| 778 | : defined $3 ? chr hex $3 | ||||
| 779 | : defined $4 ? chr hex $4 | ||||
| 780 | : chr hex $5; | ||||
| 781 | $decoded .= $dec; | ||||
| 782 | $last = 0; | ||||
| 783 | } | ||||
| 784 | if ($$yaml =~ s/\A([ \t]+)//) { | ||||
| 785 | my $spaces = $1; | ||||
| 786 | if (length $$yaml) { | ||||
| 787 | $quoted .= $spaces; | ||||
| 788 | $decoded .= $spaces; | ||||
| 789 | $last = 0; | ||||
| 790 | } | ||||
| 791 | else { | ||||
| 792 | $eol = $spaces; | ||||
| 793 | last; | ||||
| 794 | } | ||||
| 795 | } | ||||
| 796 | if ($$yaml =~ s/\A(\\)\z//) { | ||||
| 797 | $quoted .= $1; | ||||
| 798 | $decoded .= $1; | ||||
| 799 | last; | ||||
| 800 | } | ||||
| 801 | last if $last; | ||||
| 802 | } | ||||
| 803 | return ($quoted, $decoded, $eol); | ||||
| 804 | } | ||||
| 805 | |||||
| 806 | sub _fetch_next_tokens_directive { | ||||
| 807 | my ($self, $yaml, $eol) = @_; | ||||
| 808 | my @tokens; | ||||
| 809 | |||||
| 810 | my $trailing_ws = ''; | ||||
| 811 | my $warn = $ENV{YAML_PP_RESERVED_DIRECTIVE} || 'warn'; | ||||
| 812 | if ($$yaml =~ s/\A(\s*%YAML[ \t]+([0-9]+\.[0-9]+))//) { | ||||
| 813 | my $dir = $1; | ||||
| 814 | my $version = $2; | ||||
| 815 | if ($$yaml =~ s/\A($RE_WS+)//) { | ||||
| 816 | $trailing_ws = $1; | ||||
| 817 | } | ||||
| 818 | elsif (length $$yaml) { | ||||
| 819 | push @tokens, ( 'Invalid directive' => $dir.$$yaml.$eol, $self->line ); | ||||
| 820 | $self->_push_tokens(\@tokens); | ||||
| 821 | return; | ||||
| 822 | } | ||||
| 823 | if ($version !~ m/^1\.[12]$/) { | ||||
| 824 | if ($warn eq 'warn') { | ||||
| 825 | warn "Unsupported YAML version '$dir'"; | ||||
| 826 | } | ||||
| 827 | elsif ($warn eq 'fatal') { | ||||
| 828 | push @tokens, ( 'Unsupported YAML version' => $dir, $self->line ); | ||||
| 829 | $self->_push_tokens(\@tokens); | ||||
| 830 | return; | ||||
| 831 | } | ||||
| 832 | } | ||||
| 833 | push @tokens, ( YAML_DIRECTIVE => $dir, $self->line ); | ||||
| 834 | } | ||||
| 835 | elsif ($$yaml =~ s/\A(\s*%TAG[ \t]+(!$RE_NS_WORD_CHAR*!|!)[ \t]+(tag:\S+|!$RE_URI_CHAR+))($RE_WS*)//) { | ||||
| 836 | push @tokens, ( TAG_DIRECTIVE => $1, $self->line ); | ||||
| 837 | # TODO | ||||
| 838 | my $tag_alias = $2; | ||||
| 839 | my $tag_url = $3; | ||||
| 840 | $trailing_ws = $4; | ||||
| 841 | } | ||||
| 842 | elsif ($$yaml =~ s/\A(\s*\A%(?:\w+).*)//) { | ||||
| 843 | push @tokens, ( RESERVED_DIRECTIVE => $1, $self->line ); | ||||
| 844 | if ($warn eq 'warn') { | ||||
| 845 | warn "Found reserved directive '$1'"; | ||||
| 846 | } | ||||
| 847 | elsif ($warn eq 'fatal') { | ||||
| 848 | die "Found reserved directive '$1'"; | ||||
| 849 | } | ||||
| 850 | } | ||||
| 851 | else { | ||||
| 852 | push @tokens, ( 'Invalid directive' => $$yaml, $self->line ); | ||||
| 853 | push @tokens, ( EOL => $eol, $self->line ); | ||||
| 854 | $self->_push_tokens(\@tokens); | ||||
| 855 | return; | ||||
| 856 | } | ||||
| 857 | if (not length $$yaml) { | ||||
| 858 | push @tokens, ( EOL => $eol, $self->line ); | ||||
| 859 | } | ||||
| 860 | elsif ($trailing_ws and $$yaml =~ s/\A(#.*)?\z//) { | ||||
| 861 | push @tokens, ( EOL => "$trailing_ws$1$eol", $self->line ); | ||||
| 862 | $self->_push_tokens(\@tokens); | ||||
| 863 | return; | ||||
| 864 | } | ||||
| 865 | elsif ($$yaml =~ s/\A([ \t]+#.*)?\z//) { | ||||
| 866 | push @tokens, ( EOL => "$1$eol", $self->line ); | ||||
| 867 | $self->_push_tokens(\@tokens); | ||||
| 868 | return; | ||||
| 869 | } | ||||
| 870 | else { | ||||
| 871 | push @tokens, ( 'Invalid directive' => $trailing_ws.$$yaml, $self->line ); | ||||
| 872 | push @tokens, ( EOL => $eol, $self->line ); | ||||
| 873 | } | ||||
| 874 | $self->_push_tokens(\@tokens); | ||||
| 875 | return; | ||||
| 876 | } | ||||
| 877 | |||||
| 878 | # spent 682ms (585+96.5) within YAML::PP::Lexer::_push_tokens which was called 61194 times, avg 11µs/call:
# 18718 times (171ms+29.7ms) by YAML::PP::Lexer::_fetch_next_tokens at line 356, avg 11µs/call
# 13720 times (120ms+21.7ms) by YAML::PP::Lexer::fetch_plain at line 396, avg 10µs/call
# 13354 times (122ms+20.2ms) by YAML::PP::Lexer::fetch_next_tokens at line 217, avg 11µs/call
# 6420 times (69.3ms+9.75ms) by YAML::PP::Lexer::_fetch_next_tokens at line 304, avg 12µs/call
# 4998 times (60.6ms+9.01ms) by YAML::PP::Lexer::fetch_plain at line 505, avg 14µs/call
# 2046 times (22.8ms+3.18ms) by YAML::PP::Lexer::_fetch_next_tokens at line 279, avg 13µs/call
# 1413 times (12.0ms+2.11ms) by YAML::PP::Lexer::fetch_quoted at line 705, avg 10µs/call
# 523 times (6.74ms+908µs) by YAML::PP::Lexer::_fetch_next_tokens at line 257, avg 15µs/call
# once (21µs+3µs) by YAML::PP::Lexer::fetch_next_tokens at line 208
# once (6µs+2µs) by YAML::PP::Lexer::fetch_block at line 614 | ||||
| 879 | 61194 | 10.4ms | my ($self, $new_tokens) = @_; | ||
| 880 | 61194 | 34.8ms | 61194 | 26.4ms | my $next = $self->next_tokens; # spent 26.4ms making 61194 calls to YAML::PP::Lexer::next_tokens, avg 431ns/call |
| 881 | 61194 | 28.6ms | 61194 | 19.7ms | my $line = $self->line; # spent 19.7ms making 61194 calls to YAML::PP::Lexer::line, avg 322ns/call |
| 882 | 61194 | 30.4ms | 61194 | 20.9ms | my $column = $self->offset; # spent 20.9ms making 61194 calls to YAML::PP::Lexer::offset, avg 341ns/call |
| 883 | |||||
| 884 | 61194 | 56.4ms | for (my $i = 0; $i < @$new_tokens; $i += 3) { | ||
| 885 | 90100 | 23.5ms | my $value = $new_tokens->[ $i + 1 ]; | ||
| 886 | 90100 | 17.9ms | my $name = $new_tokens->[ $i ]; | ||
| 887 | 90100 | 13.3ms | my $line = $new_tokens->[ $i + 2 ]; | ||
| 888 | 90100 | 85.4ms | my $push = { | ||
| 889 | name => $name, | ||||
| 890 | line => $line, | ||||
| 891 | column => $column, | ||||
| 892 | value => $value, | ||||
| 893 | }; | ||||
| 894 | 90100 | 24.7ms | $column += length $value unless $name eq 'CONTEXT'; | ||
| 895 | 90100 | 12.9ms | push @$next, $push; | ||
| 896 | 90100 | 25.4ms | if ($name eq 'EOL') { | ||
| 897 | $column = 0; | ||||
| 898 | } | ||||
| 899 | } | ||||
| 900 | 61194 | 34.6ms | 61194 | 29.5ms | $self->set_offset($column); # spent 29.5ms making 61194 calls to YAML::PP::Lexer::set_offset, avg 483ns/call |
| 901 | 61194 | 81.0ms | return $next; | ||
| 902 | } | ||||
| 903 | |||||
| 904 | sub push_subtokens { | ||||
| 905 | 2046 | 574µs | my ($self, $token, $subtokens) = @_; | ||
| 906 | 2046 | 1.57ms | 2046 | 977µs | my $next = $self->next_tokens; # spent 977µs making 2046 calls to YAML::PP::Lexer::next_tokens, avg 478ns/call |
| 907 | 2046 | 1.77ms | 2046 | 657µs | my $line = $self->line; # spent 657µs making 2046 calls to YAML::PP::Lexer::line, avg 321ns/call |
| 908 | 2046 | 1.23ms | 2046 | 935µs | my $column = $self->offset; # spent 935µs making 2046 calls to YAML::PP::Lexer::offset, avg 457ns/call |
| 909 | 2046 | 837µs | $token->{column} = $column; | ||
| 910 | 2046 | 941µs | $token->{subtokens} = \my @sub; | ||
| 911 | |||||
| 912 | 2046 | 3.32ms | for (my $i = 0; $i < @$subtokens; $i+=3) { | ||
| 913 | 6152 | 2.95ms | my $name = $subtokens->[ $i ]; | ||
| 914 | 6152 | 2.54ms | my $value = $subtokens->[ $i + 1 ]; | ||
| 915 | 6152 | 1.32ms | my $line = $subtokens->[ $i + 2 ]; | ||
| 916 | 6152 | 4.99ms | my $push = { | ||
| 917 | name => $subtokens->[ $i ], | ||||
| 918 | line => $line, | ||||
| 919 | column => $column, | ||||
| 920 | }; | ||||
| 921 | 6152 | 2.42ms | if (ref $value eq 'HASH') { | ||
| 922 | 2045 | 5.75ms | %$push = ( %$push, %$value ); | ||
| 923 | 2045 | 1.31ms | $column += length $value->{orig}; | ||
| 924 | } | ||||
| 925 | else { | ||||
| 926 | 4107 | 1.58ms | $push->{value} = $value; | ||
| 927 | 4107 | 855µs | $column += length $value; | ||
| 928 | } | ||||
| 929 | 6152 | 1.36ms | if ($push->{name} eq 'EOL') { | ||
| 930 | $column = 0; | ||||
| 931 | } | ||||
| 932 | 6152 | 2.02ms | push @sub, $push; | ||
| 933 | } | ||||
| 934 | 2046 | 927µs | $token->{line} = $sub[0]->{line}; | ||
| 935 | 2046 | 617µs | push @$next, $token; | ||
| 936 | 2046 | 2.01ms | 2046 | 1.56ms | $self->set_offset($column); # spent 1.56ms making 2046 calls to YAML::PP::Lexer::set_offset, avg 761ns/call |
| 937 | 2046 | 3.04ms | return $next; | ||
| 938 | } | ||||
| 939 | |||||
| 940 | sub exception { | ||||
| 941 | my ($self, $msg) = @_; | ||||
| 942 | my $next = $self->next_tokens; | ||||
| 943 | $next = []; | ||||
| 944 | my $line = @$next ? $next->[0]->{line} : $self->line; | ||||
| 945 | my @caller = caller(0); | ||||
| 946 | my $yaml = ''; | ||||
| 947 | if (my $nl = $self->next_line) { | ||||
| 948 | $yaml = join '', @$nl; | ||||
| 949 | $yaml = $nl->[1]; | ||||
| 950 | } | ||||
| 951 | my $e = YAML::PP::Exception->new( | ||||
| 952 | line => $line, | ||||
| 953 | column => $self->offset + 1, | ||||
| 954 | msg => $msg, | ||||
| 955 | next => $next, | ||||
| 956 | where => $caller[1] . ' line ' . $caller[2], | ||||
| 957 | yaml => $yaml, | ||||
| 958 | ); | ||||
| 959 | croak $e; | ||||
| 960 | } | ||||
| 961 | |||||
| 962 | 1 | 40µs | 1; | ||
sub YAML::PP::Lexer::CORE:match; # opcode | |||||
# spent 29µs within YAML::PP::Lexer::CORE:qr which was called 11 times, avg 3µs/call:
# 4 times (14µs+0s) by YAML::PP::Parser::BEGIN@18 at line 127, avg 4µs/call
# once (5µs+0s) by YAML::PP::Parser::BEGIN@18 at line 50
# once (3µs+0s) by YAML::PP::Parser::BEGIN@18 at line 52
# once (2µs+0s) by YAML::PP::Parser::BEGIN@18 at line 120
# once (2µs+0s) by YAML::PP::Parser::BEGIN@18 at line 51
# once (1µs+0s) by YAML::PP::Parser::BEGIN@18 at line 122
# once (1µs+0s) by YAML::PP::Parser::BEGIN@18 at line 121
# once (1µs+0s) by YAML::PP::Parser::BEGIN@18 at line 234 | |||||
# spent 154ms within YAML::PP::Lexer::CORE:regcomp which was called 58385 times, avg 3µs/call:
# 18718 times (105ms+0s) by YAML::PP::Lexer::fetch_plain at line 376, avg 6µs/call
# 18718 times (14.0ms+0s) by YAML::PP::Lexer::fetch_plain at line 383, avg 746ns/call
# 13953 times (29.8ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 284, avg 2µs/call
# 2045 times (1.82ms+0s) by YAML::PP::Lexer::_read_quoted_tokens at line 724, avg 890ns/call
# 2045 times (1.13ms+0s) by YAML::PP::Lexer::fetch_quoted at line 625, avg 551ns/call
# 2045 times (851µs+0s) by YAML::PP::Lexer::_read_quoted_tokens at line 741, avg 416ns/call
# 666 times (386µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 329, avg 580ns/call
# 88 times (65µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 270, avg 739ns/call
# 88 times (52µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 264, avg 591ns/call
# 6 times (37µs+0s) by YAML::PP::Lexer::fetch_next_tokens at line 208, avg 6µs/call
# 3 times (237µs+0s) by YAML::PP::Parser::BEGIN@18 at line 127, avg 79µs/call
# 3 times (17µs+0s) by YAML::PP::Lexer::fetch_plain at line 427, avg 6µs/call
# once (141µs+0s) by YAML::PP::Parser::BEGIN@18 at line 52
# once (22µs+0s) by YAML::PP::Parser::BEGIN@18 at line 50
# once (18µs+0s) by YAML::PP::Parser::BEGIN@18 at line 120
# once (13µs+0s) by YAML::PP::Parser::BEGIN@18 at line 122
# once (12µs+0s) by YAML::PP::Parser::BEGIN@18 at line 121
# once (12µs+0s) by YAML::PP::Parser::BEGIN@18 at line 51
# once (5µs+0s) by YAML::PP::Lexer::fetch_block at line 525 | |||||
# spent 148ms within YAML::PP::Lexer::CORE:subst which was called 75042 times, avg 2µs/call:
# 18718 times (82.7ms+0s) by YAML::PP::Lexer::fetch_plain at line 376, avg 4µs/call
# 18718 times (19.0ms+0s) by YAML::PP::Lexer::fetch_plain at line 383, avg 1µs/call
# 13953 times (20.0ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 284, avg 1µs/call
# 13953 times (13.5ms+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 302, avg 969ns/call
# 2045 times (4.16ms+0s) by YAML::PP::Lexer::_read_quoted_tokens at line 724, avg 2µs/call
# 2045 times (3.99ms+0s) by YAML::PP::Lexer::fetch_quoted at line 625, avg 2µs/call
# 2045 times (2.03ms+0s) by YAML::PP::Lexer::_read_quoted_tokens at line 741, avg 994ns/call
# 2045 times (1.29ms+0s) by YAML::PP::Lexer::_read_quoted_tokens at line 727, avg 632ns/call
# 666 times (753µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 329, avg 1µs/call
# 666 times (595µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 331, avg 893ns/call
# 88 times (41µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 264, avg 466ns/call
# 88 times (26µs+0s) by YAML::PP::Lexer::_fetch_next_tokens at line 270, avg 295ns/call
# 6 times (6µs+0s) by YAML::PP::Lexer::fetch_next_tokens at line 208, avg 1µs/call
# 3 times (3µs+0s) by YAML::PP::Lexer::fetch_plain at line 427, avg 1µs/call
# 2 times (3µs+0s) by YAML::PP::Lexer::fetch_block at line 531, avg 2µs/call
# once (1µs+0s) by YAML::PP::Lexer::fetch_block at line 525 |