File tree Expand file tree Collapse file tree 2 files changed +43
-21
lines changed
src/main/java/ch/njol/skript/timings Expand file tree Collapse file tree 2 files changed +43
-21
lines changed Original file line number Diff line number Diff line change 21
21
22
22
package ch .njol .skript .timings ;
23
23
24
- /**
25
- *
26
- */
24
+ import java .util .ArrayList ;
25
+ import java .util .List ;
26
+
27
+ import com .google .common .collect .Lists ;
28
+
27
29
public class Timing {
28
30
31
+ public class Capture {
32
+
33
+ Timing parent ;
34
+
35
+ protected Capture (Timing parent ) {
36
+ this .parent = parent ;
37
+ }
38
+
39
+ public void start () {
40
+
41
+ }
42
+ }
43
+
44
+ private List <Capture > captures = new ArrayList <Capture >();
45
+
46
+ /**
47
+ * Creates a new timing. Only used for {@link Timings}
48
+ */
49
+ protected Timing () {
50
+ captures = new ArrayList <Capture >();
51
+ }
52
+
53
+ /**
54
+ * Creates a capture for timing.
55
+ * @return
56
+ */
57
+ public Capture capture () {
58
+ return new Capture (this );
59
+ }
29
60
}
Original file line number Diff line number Diff line change 31
31
*/
32
32
public class Timings {
33
33
34
- static class TimingObject extends HashMap <String ,Timing > {}
34
+ private static Map < String , Timing > timings = new HashMap <String ,Timing >();
35
35
36
- private static Map <Object ,TimingObject > timings = new HashMap <Object ,TimingObject >();
37
-
38
- public static Timing of (Object obj , String name ) {
39
- TimingObject map ;
36
+ public static Timing of (String name ) {
37
+ Timing timing ;
40
38
synchronized (timings ) {
41
- if (timings .containsKey (obj )) {
42
- map = timings .get (obj );
39
+ if (timings .containsKey (name )) {
40
+ timing = timings .get (name );
43
41
} else {
44
- map = new TimingObject ();
45
- timings .put (obj , map );
42
+ timing = new Timing ();
43
+ timings .put (name , timing );
46
44
}
47
45
}
48
46
49
- synchronized (map ) {
50
- if (map .containsKey (name )) {
51
- return map .get (name );
52
- } else {
53
- Timing timing = new Timing ();
54
- map .put (name , timing );
55
- return timing ;
56
- }
57
- }
47
+ assert timing != null ;
48
+ return timing ;
58
49
}
59
50
}
You can’t perform that action at this time.
0 commit comments