Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e4d538c63591
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 482d672e446b
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 30, 2016

  1. Copy the full SHA
    b7d8c95 View commit details
  2. Copy the full SHA
    904be35 View commit details
  3. Copy the full SHA
    f9a5f31 View commit details
  4. Copy the full SHA
    482d672 View commit details
1 change: 0 additions & 1 deletion spec/truffle/tags/truffle/string/unpack_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@

public abstract class LoopRecovery {

private static final String DIRECTIVES = "CSLQcslqInjJNvVUwDdFfEeFfAaZBbHhuMmpPXx@";

/**
* Format strings can sometimes be dynamically generated with code such as:
* <p>
@@ -32,8 +34,8 @@ public abstract class LoopRecovery {
* for one simple loop.
* <p>
* To do that, for each character we look 1..n characters behind and see if
* that pattern is repeated. If it is we have the loop. Nothing more
* complicated than that.
* that pattern is repeated. If it is we have the loop. We then keep going
* and see how many more times we can loop. Nothing more complicated than that.
*/
public static String recoverLoop(String format) {
// The index is the point in the format string where we look backwards for loops from
@@ -45,7 +47,7 @@ public static String recoverLoop(String format) {
while (index < format.length()) {
// If we aren't at the start of a new directive, step forward one

if ("CSLQcslqInNvVUwDdFfEeFfAaZBbHhuMmpPXx@".indexOf(format.charAt(index)) == -1) {
if (DIRECTIVES.indexOf(format.charAt(index)) == -1) {
index++;
continue;
}
@@ -63,12 +65,17 @@ public static String recoverLoop(String format) {

while (tryLengthOfLoopedString <= index && index + tryLengthOfLoopedString <= format.length()) {
// If that length of string exists both before and after the index then that's a successful length
// to use for looping
// to use for looping. The loop must be followed by a new directive. We don't handle whitespace well
// here at the moment, as the whitespace won't count as a new directive.

final String beforeIndex = format.substring(index - tryLengthOfLoopedString, index);
final String afterIndex = format.substring(index, index + tryLengthOfLoopedString);

if (beforeIndex.equals(afterIndex)) {
final boolean repetitionExists = beforeIndex.equals(afterIndex);
final boolean charactersAfterRepetition = index + tryLengthOfLoopedString < format.length();

if (repetitionExists && !(charactersAfterRepetition
&& DIRECTIVES.indexOf(format.charAt(index + tryLengthOfLoopedString)) == -1)) {
successfulLengthOfLoopedString = tryLengthOfLoopedString;
}

@@ -90,17 +97,17 @@ public static String recoverLoop(String format) {

// Where in the string the 2 repetitions end

int indexOfEndOfRepititions = index + successfulLengthOfLoopedString;
int indexOfEndOfRepetitions = index + successfulLengthOfLoopedString;

// Loop to find out how many times the string appears after the 2 initial instances

while (indexOfEndOfRepititions + successfulLengthOfLoopedString <= format.length()) {
if (!format.substring(indexOfEndOfRepititions, indexOfEndOfRepititions + successfulLengthOfLoopedString).equals(repeated)) {
while (indexOfEndOfRepetitions + successfulLengthOfLoopedString <= format.length()) {
if (!format.substring(indexOfEndOfRepetitions, indexOfEndOfRepetitions + successfulLengthOfLoopedString).equals(repeated)) {
break;
}

repetitionsCount++;
indexOfEndOfRepititions += successfulLengthOfLoopedString;
indexOfEndOfRepetitions += successfulLengthOfLoopedString;
}

// Replace 'nnn' with 'n3'
@@ -111,7 +118,7 @@ public static String recoverLoop(String format) {
builder.append(repeated);
builder.append(')');
builder.append(repetitionsCount);
builder.append(format.substring(indexOfEndOfRepititions));
builder.append(format.substring(indexOfEndOfRepetitions));

format = builder.toString();
}
Original file line number Diff line number Diff line change
@@ -250,8 +250,7 @@ public void startSubSequence() {

@Override
public void finishSubSequence(int count) {
final List<FormatNode> sequence = sequenceStack.pop();
appendNode(new SequenceNode(context, sequence.toArray(new FormatNode[sequence.size()])));
appendNode(sharedTreeBuilder.finishSubSequence(sequenceStack, count));
}

@Override