Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Vocabulary/Content.pm |
Statements | Executed 56 statements in 1.24ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 50µs | 53µs | BEGIN@1.316 | Module::Runtime::
1 | 1 | 1 | 48µs | 74µs | BEGIN@2.317 | Module::Runtime::
1 | 1 | 1 | 35µs | 71µs | BEGIN@13 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 33µs | 41µs | BEGIN@16 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 20µs | 1.26ms | BEGIN@11 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 20µs | 25µs | _traverse_keyword_contentEncoding | JSON::Schema::Modern::Vocabulary::Content::
2 | 2 | 1 | 14µs | 14µs | keywords | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 14µs | 14µs | BEGIN@9 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 14µs | 86µs | _traverse_keyword_contentSchema | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 13µs | 554µs | BEGIN@10 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 12µs | 32µs | BEGIN@14 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 9µs | 18µs | BEGIN@15 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 9µs | 41µs | BEGIN@19 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 8µs | 114µs | BEGIN@12 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 7µs | 33µs | BEGIN@17 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 6µs | 168µs | BEGIN@20 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 5µs | 28µs | BEGIN@18 | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 4µs | 29µs | _traverse_keyword_contentMediaType | JSON::Schema::Modern::Vocabulary::Content::
3 | 1 | 1 | 3µs | 3µs | evaluation_order | JSON::Schema::Modern::Vocabulary::Content::
1 | 1 | 1 | 2µs | 2µs | vocabulary | JSON::Schema::Modern::Vocabulary::Content::
0 | 0 | 0 | 0s | 0s | _eval_keyword_contentEncoding | JSON::Schema::Modern::Vocabulary::Content::
0 | 0 | 0 | 0s | 0s | _eval_keyword_contentMediaType | JSON::Schema::Modern::Vocabulary::Content::
0 | 0 | 0 | 0s | 0s | _eval_keyword_contentSchema | JSON::Schema::Modern::Vocabulary::Content::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 65µs | 2 | 56µs | # spent 53µs (50+3) within Module::Runtime::BEGIN@1.316 which was called:
# once (50µs+3µs) by Module::Runtime::require_module at line 1 # spent 53µs making 1 call to Module::Runtime::BEGIN@1.316
# spent 3µs making 1 call to strict::import |
2 | 2 | 86µs | 2 | 100µs | # spent 74µs (48+26) within Module::Runtime::BEGIN@2.317 which was called:
# once (48µs+26µs) by Module::Runtime::require_module at line 2 # spent 74µs making 1 call to Module::Runtime::BEGIN@2.317
# spent 26µs making 1 call to warnings::import |
3 | package JSON::Schema::Modern::Vocabulary::Content; | ||||
4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||
5 | # ABSTRACT: Implementation of the JSON Schema Content vocabulary | ||||
6 | |||||
7 | 1 | 1µs | our $VERSION = '0.556'; | ||
8 | |||||
9 | 2 | 75µs | 1 | 14µs | # spent 14µs within JSON::Schema::Modern::Vocabulary::Content::BEGIN@9 which was called:
# once (14µs+0s) by Module::Runtime::require_module at line 9 # spent 14µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@9 |
10 | 2 | 50µs | 2 | 1.09ms | # spent 554µs (13+541) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@10 which was called:
# once (13µs+541µs) by Module::Runtime::require_module at line 10 # spent 554µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@10
# spent 541µs making 1 call to Moo::import |
11 | 3 | 96µs | 3 | 2.50ms | # spent 1.26ms (20µs+1.24) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@11 which was called:
# once (20µs+1.24ms) by Module::Runtime::require_module at line 11 # spent 1.26ms making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@11
# spent 1.22ms making 1 call to strictures::import
# spent 25µs making 1 call to strictures::VERSION |
12 | 2 | 118µs | 2 | 220µs | # spent 114µs (8+106) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@12 which was called:
# once (8µs+106µs) by Module::Runtime::require_module at line 12 # spent 114µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@12
# spent 106µs making 1 call to experimental::import |
13 | 2 | 65µs | 2 | 75µs | # spent 71µs (35+36) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@13 which was called:
# once (35µs+36µs) by Module::Runtime::require_module at line 13 # spent 71µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@13
# spent 4µs making 1 call to if::import |
14 | 2 | 27µs | 2 | 35µs | # spent 32µs (12+20) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@14 which was called:
# once (12µs+20µs) by Module::Runtime::require_module at line 14 # spent 32µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@14
# spent 3µs making 1 call to if::unimport |
15 | 2 | 43µs | 2 | 18µs | # spent 18µs (9+9) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@15 which was called:
# once (9µs+9µs) by Module::Runtime::require_module at line 15 # spent 18µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@15
# spent 0s making 1 call to if::unimport |
16 | 2 | 15µs | 2 | 42µs | # spent 41µs (33+8) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@16 which was called:
# once (33µs+8µs) by Module::Runtime::require_module at line 16 # spent 41µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@16
# spent 1µs making 1 call to if::unimport |
17 | 2 | 17µs | 2 | 59µs | # spent 33µs (7+26) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@17 which was called:
# once (7µs+26µs) by Module::Runtime::require_module at line 17 # spent 33µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@17
# spent 26µs making 1 call to Exporter::import |
18 | 2 | 18µs | 2 | 51µs | # spent 28µs (5+23) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@18 which was called:
# once (5µs+23µs) by Module::Runtime::require_module at line 18 # spent 28µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@18
# spent 23µs making 1 call to Feature::Compat::Try::import |
19 | 2 | 18µs | 2 | 73µs | # spent 41µs (9+32) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@19 which was called:
# once (9µs+32µs) by Module::Runtime::require_module at line 19 # spent 41µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@19
# spent 32µs making 1 call to Exporter::import |
20 | 2 | 465µs | 2 | 330µs | # spent 168µs (6+162) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@20 which was called:
# once (6µs+162µs) by Module::Runtime::require_module at line 20 # spent 168µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@20
# spent 162µs making 1 call to namespace::clean::import |
21 | |||||
22 | 1 | 1µs | 1 | 317µs | with 'JSON::Schema::Modern::Vocabulary'; # spent 317µs making 1 call to Moo::with |
23 | |||||
24 | # spent 2µs within JSON::Schema::Modern::Vocabulary::Content::vocabulary which was called:
# once (2µs+0s) by JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:696] at line 692 of JSON/Schema/Modern.pm | ||||
25 | 1 | 3µs | 'https://json-schema.org/draft/2019-09/vocab/content' => 'draft2019-09', | ||
26 | 'https://json-schema.org/draft/2020-12/vocab/content' => 'draft2020-12'; | ||||
27 | } | ||||
28 | |||||
29 | 3 | 6µs | # spent 3µs within JSON::Schema::Modern::Vocabulary::Content::evaluation_order which was called 3 times, avg 1µs/call:
# 3 times (3µs+0s) by JSON::Schema::Modern::Vocabulary::Core::CORE:sort at line 331 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 1µs/call | ||
30 | |||||
31 | 6 | 1µs | # spent 14µs within JSON::Schema::Modern::Vocabulary::Content::keywords which was called 2 times, avg 7µs/call:
# once (10µs+0s) by JSON::Schema::Modern::_traverse_subschema at line 471 of JSON/Schema/Modern.pm
# once (4µs+0s) by JSON::Schema::Modern::_eval_subschema at line 559 of JSON/Schema/Modern.pm | ||
32 | return ( | ||||
33 | 2 | 17µs | qw(contentEncoding contentMediaType), | ||
34 | $spec_version ne 'draft7' ? 'contentSchema' : (), | ||||
35 | ); | ||||
36 | } | ||||
37 | |||||
38 | 4 | 13µs | # spent 25µs (20+5) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding which was called:
# once (20µs+5µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType at line 59 | ||
39 | 1 | 1µs | 1 | 5µs | return if not assert_keyword_type($state, $schema, 'string'); # spent 5µs making 1 call to JSON::Schema::Modern::Utilities::assert_keyword_type |
40 | 1 | 3µs | return 1; | ||
41 | } | ||||
42 | |||||
43 | sub _eval_keyword_contentEncoding ($self, $data, $schema, $state) { | ||||
44 | return 1 if not is_type('string', $data); | ||||
45 | |||||
46 | if ($state->{validate_content_schemas}) { | ||||
47 | my $decoder = $state->{evaluator}->get_encoding($schema->{contentEncoding}); | ||||
48 | abort($state, 'cannot find decoder for contentEncoding "%s"', $schema->{contentEncoding}) | ||||
49 | if not $decoder; | ||||
50 | |||||
51 | # decode the data now, so we can report errors for the right keyword | ||||
52 | try { $state->{_content_ref} = $decoder->(\$data) } | ||||
53 | catch ($e) { return E($state, $e) } | ||||
54 | } | ||||
55 | |||||
56 | return A($state, $schema->{$state->{keyword}}) | ||||
57 | } | ||||
58 | |||||
59 | 1 | 4µs | 1 | 25µs | # spent 29µs (4+25) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType which was called:
# once (4µs+25µs) by JSON::Schema::Modern::_traverse_subschema at line 483 of JSON/Schema/Modern.pm # spent 25µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding |
60 | |||||
61 | sub _eval_keyword_contentMediaType ($self, $data, $schema, $state) { | ||||
62 | return 1 if not is_type('string', $data); | ||||
63 | |||||
64 | if ($state->{validate_content_schemas}) { | ||||
65 | my $decoder = $state->{evaluator}->get_media_type($schema->{contentMediaType}); | ||||
66 | abort($state, 'cannot find decoder for contentMediaType "%s"', $schema->{contentMediaType}) | ||||
67 | if not $decoder; | ||||
68 | |||||
69 | # contentEncoding failed to decode the content | ||||
70 | return 1 if exists $schema->{contentEncoding} and not exists $state->{_content_ref}; | ||||
71 | |||||
72 | # decode the data now, so we can report errors for the right keyword | ||||
73 | try { $state->{_content_ref} = $decoder->($state->{_content_ref} // \$data) } | ||||
74 | catch ($e) { return E($state, $e) } | ||||
75 | } | ||||
76 | |||||
77 | return A($state, $schema->{$state->{keyword}}) | ||||
78 | } | ||||
79 | |||||
80 | 4 | 0s | # spent 86µs (14+72) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentSchema which was called:
# once (14µs+72µs) by JSON::Schema::Modern::_traverse_subschema at line 483 of JSON/Schema/Modern.pm | ||
81 | # since contentSchema should never be assumed to be evaluated in the context of the containing | ||||
82 | # schema, it is not appropriate to gather identifiers found therein -- but we can still validate | ||||
83 | # the subschema. | ||||
84 | 1 | 8µs | 1 | 72µs | $self->traverse_subschema($schema, +{ %$state, identifiers => [] }); # spent 72µs making 1 call to JSON::Schema::Modern::Vocabulary::traverse_subschema |
85 | } | ||||
86 | |||||
87 | sub _eval_keyword_contentSchema ($self, $data, $schema, $state) { | ||||
88 | return 1 if not exists $schema->{contentMediaType}; | ||||
89 | return 1 if not is_type('string', $data); | ||||
90 | |||||
91 | return A($state, dclone($schema->{contentSchema})) if not $state->{validate_content_schemas}; | ||||
92 | |||||
93 | return 1 if not exists $state->{_content_ref}; # contentMediaType failed to decode the content | ||||
94 | |||||
95 | return 1 if $self->eval($state->{_content_ref}->$*, $schema->{contentSchema}, | ||||
96 | { %$state, schema_path => $state->{schema_path}.'/contentSchema' }); | ||||
97 | return E($state, 'subschema is not valid'); | ||||
98 | } | ||||
99 | |||||
100 | 1 | 6µs | 1; | ||
101 | |||||
102 | 1 | 20µs | 1 | 264µs | __END__ # spent 264µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |