Skip to content

Commit

Permalink
[Truffle] Use NotProvided to avoid an explicit guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Jan 10, 2017
1 parent ae4655b commit d5c9600
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -497,16 +497,16 @@ public LeafRope makeValidLeafRopeWithCharacterLength(byte[] bytes, Encoding enco
return new ValidLeafRope(bytes, encoding, characterLength);
}

@Specialization(guards = { "isValid(codeRange)", "isFixedWidth(encoding)", "wasNotProvided(characterLength)" })
public LeafRope makeValidLeafRopeFixedWidthEncoding(byte[] bytes, Encoding encoding, CodeRange codeRange, Object characterLength) {
@Specialization(guards = { "isValid(codeRange)", "isFixedWidth(encoding)" })
public LeafRope makeValidLeafRopeFixedWidthEncoding(byte[] bytes, Encoding encoding, CodeRange codeRange, NotProvided characterLength) {
final int calculatedCharacterLength = bytes.length / encoding.minLength();

return new ValidLeafRope(bytes, encoding, calculatedCharacterLength);
}

@TruffleBoundary
@Specialization(guards = { "isValid(codeRange)", "!isFixedWidth(encoding)", "wasNotProvided(characterLength)" })
public LeafRope makeValidLeafRope(byte[] bytes, Encoding encoding, CodeRange codeRange, Object characterLength) {
@Specialization(guards = { "isValid(codeRange)", "!isFixedWidth(encoding)" })
public LeafRope makeValidLeafRope(byte[] bytes, Encoding encoding, CodeRange codeRange, NotProvided characterLength) {
// Exctracted from StringSupport.strLength.

int calculatedCharacterLength = 0;
Expand Down

0 comments on commit d5c9600

Please sign in to comment.