File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,12 +166,7 @@ class Builder {
166166 _addNamespacePrefix ( prefixes ) {
167167 for ( const { prefix, value } of prefixes ) {
168168 const namespace = this . _searchNamespace ( value ) ;
169- let prefixStack = this . _namespacePrefixes . get ( prefix ) ;
170- if ( ! prefixStack ) {
171- prefixStack = [ ] ;
172- this . _namespacePrefixes . set ( prefix , prefixStack ) ;
173- }
174- prefixStack . push ( namespace ) ;
169+ this . _namespacePrefixes . getOrInsert ( prefix , [ ] ) . push ( namespace ) ;
175170 }
176171 }
177172
Original file line number Diff line number Diff line change @@ -48,14 +48,11 @@ class FontFinder {
4848 addPdfFont ( pdfFont ) {
4949 const cssFontInfo = pdfFont . cssFontInfo ;
5050 const name = cssFontInfo . fontFamily ;
51- let font = this . fonts . get ( name ) ;
52- if ( ! font ) {
53- font = Object . create ( null ) ;
54- this . fonts . set ( name , font ) ;
55- if ( ! this . defaultFont ) {
56- this . defaultFont = font ;
57- }
58- }
51+ const font = this . fonts . getOrInsertComputed ( name , ( ) =>
52+ Object . create ( null )
53+ ) ;
54+ this . defaultFont ??= font ;
55+
5956 let property = "" ;
6057 const fontWeight = parseFloat ( cssFontInfo . fontWeight ) ;
6158 if ( parseFloat ( cssFontInfo . italicAngle ) !== 0 ) {
Original file line number Diff line number Diff line change @@ -193,11 +193,7 @@ function searchNode(
193193 let children , cached ;
194194
195195 if ( useCache ) {
196- cached = somCache . get ( node ) ;
197- if ( ! cached ) {
198- cached = new Map ( ) ;
199- somCache . set ( node , cached ) ;
200- }
196+ cached = somCache . getOrInsertComputed ( node , ( ) => new Map ( ) ) ;
201197 children = cached . get ( cacheName ) ;
202198 }
203199
You can’t perform that action at this time.
0 commit comments