@@ -181,44 +181,25 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
181
181
/** Holds if this type path is empty. */
182
182
predicate isEmpty ( ) { this = "" }
183
183
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
-
194
184
/** Gets the length of this path. */
195
185
bindingset [ this ]
196
186
pragma [ inline_late]
197
187
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 ( )
204
192
}
205
193
206
194
/** Gets the path obtained by appending `suffix` onto this path. */
207
195
bindingset [ this , suffix]
208
196
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
+ )
222
203
}
223
204
224
205
/**
@@ -232,16 +213,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
232
213
233
214
/** Gets the path obtained by removing `prefix` from this path. */
234
215
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 }
245
217
246
218
/** Holds if this path starts with `tp`, followed by `suffix`. */
247
219
bindingset [ this ]
@@ -256,7 +228,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
256
228
TypePath nil ( ) { result .isEmpty ( ) }
257
229
258
230
/** Gets the singleton type path `tp`. */
259
- TypePath singleton ( TypeParameter tp ) { result = TypeParameter:: encode ( tp ) }
231
+ TypePath singleton ( TypeParameter tp ) { result = TypeParameter:: encode ( tp ) + "." }
260
232
261
233
/**
262
234
* Gets the type path obtained by appending the singleton type path `tp`
0 commit comments