@@ -181,44 +181,25 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
181181 /** Holds if this type path is empty. */
182182 predicate isEmpty ( ) { this = "" }
183183
184- /** Gets the length of this path, assuming the length is at least 2. */
185- bindingset [ this ]
186- pragma [ inline_late]
187- private int lengthAtLeast2 ( ) {
188- // Same as
189- // `result = strictcount(this.indexOf(".")) + 1`
190- // but performs better because it doesn't use an aggregate
191- result = this .regexpReplaceAll ( "[0-9]+" , "" ) .length ( ) + 1
192- }
193-
194184 /** Gets the length of this path. */
195185 bindingset [ this ]
196186 pragma [ inline_late]
197187 int length ( ) {
198- if this .isEmpty ( )
199- then result = 0
200- else
201- if exists ( TypeParameter:: decode ( this ) )
202- then result = 1
203- else result = this .lengthAtLeast2 ( )
188+ // Same as
189+ // `result = count(this.indexOf("."))`
190+ // but performs better because it doesn't use an aggregate
191+ result = this .regexpReplaceAll ( "[0-9]+" , "" ) .length ( )
204192 }
205193
206194 /** Gets the path obtained by appending `suffix` onto this path. */
207195 bindingset [ this , suffix]
208196 TypePath append ( TypePath suffix ) {
209- if this .isEmpty ( )
210- then result = suffix
211- else
212- if suffix .isEmpty ( )
213- then result = this
214- else (
215- result = this + "." + suffix and
216- (
217- not exists ( getTypePathLimit ( ) )
218- or
219- result .lengthAtLeast2 ( ) <= getTypePathLimit ( )
220- )
221- )
197+ result = this + suffix and
198+ (
199+ not exists ( getTypePathLimit ( ) )
200+ or
201+ result .length ( ) <= getTypePathLimit ( )
202+ )
222203 }
223204
224205 /**
@@ -232,16 +213,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
232213
233214 /** Gets the path obtained by removing `prefix` from this path. */
234215 bindingset [ this , prefix]
235- TypePath stripPrefix ( TypePath prefix ) {
236- if prefix .isEmpty ( )
237- then result = this
238- else (
239- this = prefix and
240- result .isEmpty ( )
241- or
242- this = prefix + "." + result
243- )
244- }
216+ TypePath stripPrefix ( TypePath prefix ) { this = prefix + result }
245217
246218 /** Holds if this path starts with `tp`, followed by `suffix`. */
247219 bindingset [ this ]
@@ -256,7 +228,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
256228 TypePath nil ( ) { result .isEmpty ( ) }
257229
258230 /** Gets the singleton type path `tp`. */
259- TypePath singleton ( TypeParameter tp ) { result = TypeParameter:: encode ( tp ) }
231+ TypePath singleton ( TypeParameter tp ) { result = TypeParameter:: encode ( tp ) + "." }
260232
261233 /**
262234 * Gets the type path obtained by appending the singleton type path `tp`
0 commit comments