@@ -108,25 +108,21 @@ let _contributorsParser: ContributorsParserMaybeWithStats | undefined;
108108let _contributorsParserWithStats : ContributorsParserMaybeWithStats | undefined ;
109109export function getContributorsParser ( stats ?: boolean ) : ContributorsParserMaybeWithStats {
110110 if ( stats ) {
111- if ( _contributorsParserWithStats == null ) {
112- _contributorsParserWithStats = createLogParserWithStats ( {
113- sha : '%H' ,
114- author : '%aN' ,
115- email : '%aE' ,
116- date : '%at' ,
117- } ) ;
118- }
119- return _contributorsParserWithStats ;
120- }
121-
122- if ( _contributorsParser == null ) {
123- _contributorsParser = createLogParser ( {
111+ _contributorsParserWithStats ??= createLogParserWithStats ( {
124112 sha : '%H' ,
125113 author : '%aN' ,
126114 email : '%aE' ,
127115 date : '%at' ,
128116 } ) ;
117+ return _contributorsParserWithStats ;
129118 }
119+
120+ _contributorsParser ??= createLogParser ( {
121+ sha : '%H' ,
122+ author : '%aN' ,
123+ email : '%aE' ,
124+ date : '%at' ,
125+ } ) ;
130126 return _contributorsParser ;
131127}
132128
@@ -146,23 +142,7 @@ let _graphParserWithStats: GraphParserMaybeWithStats | undefined;
146142
147143export function getGraphParser ( stats ?: boolean ) : GraphParserMaybeWithStats {
148144 if ( stats ) {
149- if ( _graphParserWithStats == null ) {
150- _graphParserWithStats = createLogParserWithStats ( {
151- sha : '%H' ,
152- author : '%aN' ,
153- authorEmail : '%aE' ,
154- authorDate : '%at' ,
155- committerDate : '%ct' ,
156- parents : '%P' ,
157- tips : '%D' ,
158- message : '%B' ,
159- } ) ;
160- }
161- return _graphParserWithStats ;
162- }
163-
164- if ( _graphParser == null ) {
165- _graphParser = createLogParser ( {
145+ _graphParserWithStats ??= createLogParserWithStats ( {
166146 sha : '%H' ,
167147 author : '%aN' ,
168148 authorEmail : '%aE' ,
@@ -172,40 +152,46 @@ export function getGraphParser(stats?: boolean): GraphParserMaybeWithStats {
172152 tips : '%D' ,
173153 message : '%B' ,
174154 } ) ;
155+ return _graphParserWithStats ;
175156 }
157+
158+ _graphParser ??= createLogParser ( {
159+ sha : '%H' ,
160+ author : '%aN' ,
161+ authorEmail : '%aE' ,
162+ authorDate : '%at' ,
163+ committerDate : '%ct' ,
164+ parents : '%P' ,
165+ tips : '%D' ,
166+ message : '%B' ,
167+ } ) ;
176168 return _graphParser ;
177169}
178170
179171let _graphStatsParser : ParserWithStats < { sha : string } > | undefined ;
180172
181173export function getGraphStatsParser ( ) : ParserWithStats < { sha : string } > {
182- if ( _graphStatsParser == null ) {
183- _graphStatsParser = createLogParserWithStats ( { sha : '%H' } ) ;
184- }
174+ _graphStatsParser ??= createLogParserWithStats ( { sha : '%H' } ) ;
185175 return _graphStatsParser ;
186176}
187177
188178type RefParser = Parser < string > ;
189179
190180let _refParser : RefParser | undefined ;
191181export function getRefParser ( ) : RefParser {
192- if ( _refParser == null ) {
193- _refParser = createLogParserSingle ( '%H' ) ;
194- }
182+ _refParser ??= createLogParserSingle ( '%H' ) ;
195183 return _refParser ;
196184}
197185
198186type RefAndDateParser = Parser < { sha : string ; authorDate : string ; committerDate : string } > ;
199187
200188let _refAndDateParser : RefAndDateParser | undefined ;
201189export function getRefAndDateParser ( ) : RefAndDateParser {
202- if ( _refAndDateParser == null ) {
203- _refAndDateParser = createLogParser ( {
204- sha : '%H' ,
205- authorDate : '%at' ,
206- committerDate : '%ct' ,
207- } ) ;
208- }
190+ _refAndDateParser ??= createLogParser ( {
191+ sha : '%H' ,
192+ authorDate : '%at' ,
193+ committerDate : '%ct' ,
194+ } ) ;
209195 return _refAndDateParser ;
210196}
211197
0 commit comments