removed recursion in message.getMerged*()
This commit is contained in:
parent
8924c448d1
commit
8f14d2bfbd
|
@ -416,11 +416,14 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMergedBody() {
|
public String getMergedBody() {
|
||||||
final Message next = this.next();
|
StringBuilder body = new StringBuilder(this.body.trim());
|
||||||
if (this.mergeable(next)) {
|
Message current = this;
|
||||||
return getBody().trim() + MERGE_SEPARATOR + next.getMergedBody();
|
while(current.mergeable(current.next())) {
|
||||||
|
current = current.next();
|
||||||
|
body.append(MERGE_SEPARATOR);
|
||||||
|
body.append(current.getBody().trim());
|
||||||
}
|
}
|
||||||
return getBody().trim();
|
return body.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMeCommand() {
|
public boolean hasMeCommand() {
|
||||||
|
@ -428,20 +431,23 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMergedStatus() {
|
public int getMergedStatus() {
|
||||||
final Message next = this.next();
|
int status = this.status;
|
||||||
if (this.mergeable(next)) {
|
Message current = this;
|
||||||
return next.getStatus();
|
while(current.mergeable(current.next())) {
|
||||||
|
current = current.next();
|
||||||
|
status = current.status;
|
||||||
}
|
}
|
||||||
return getStatus();
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMergedTimeSent() {
|
public long getMergedTimeSent() {
|
||||||
Message next = this.next();
|
long time = this.timeSent;
|
||||||
if (this.mergeable(next)) {
|
Message current = this;
|
||||||
return next.getMergedTimeSent();
|
while(current.mergeable(current.next())) {
|
||||||
} else {
|
current = current.next();
|
||||||
return getTimeSent();
|
time = current.timeSent;
|
||||||
}
|
}
|
||||||
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasMergedIntoPrevious() {
|
public boolean wasMergedIntoPrevious() {
|
||||||
|
|
Loading…
Reference in a new issue