You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2013/06/06 19:08:59 UTC
svn commit: r1490361 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java
Author: jukka
Date: Thu Jun 6 17:08:58 2013
New Revision: 1490361
URL: http://svn.apache.org/r1490361
Log:
OAK-799: Fail-fast for content diffs
Streamline EditorDiff to reduce the number of stack frames in profiler reports
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java?rev=1490361&r1=1490360&r2=1490361&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java Thu Jun 6 17:08:58 2013
@@ -45,11 +45,20 @@ public class EditorDiff implements NodeS
checkNotNull(before);
checkNotNull(after);
if (editor != null) {
- EditorDiff diff = new EditorDiff(editor);
- return diff.process(before, after);
- } else {
- return null;
+ try {
+ editor.enter(before, after);
+
+ EditorDiff diff = new EditorDiff(editor);
+ if (!after.compareAgainstBaseState(before, diff)) {
+ return diff.exception;
+ }
+
+ editor.leave(before, after);
+ } catch (CommitFailedException e) {
+ return e;
+ }
}
+ return null;
}
private final Editor editor;
@@ -65,27 +74,6 @@ public class EditorDiff implements NodeS
this.editor = editor;
}
- private CommitFailedException process(NodeState before, NodeState after) {
- try {
- editor.enter(before, after);
- } catch (CommitFailedException e) {
- return e;
- }
-
- after.compareAgainstBaseState(before, this);
- if (exception != null) {
- return exception;
- }
-
- try {
- editor.leave(before, after);
- } catch (CommitFailedException e) {
- return e;
- }
-
- return null;
- }
-
//-------------------------------------------------< NodeStateDiff >--
@Override