76a209487303105ffc09eb4248bf2f3518885007
[deliverable/tracecompass.git] / org.eclipse.tracecompass.ctf.core / src / org / eclipse / tracecompass / ctf / core / event / scope / RootScope.java
1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.ctf.core.event.scope;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19 * A lttng specific speedup node a root with accelerated returns for some scopes
20 * of a lexical scope
21 *
22 * @author Matthew Khouzam
23 */
24 @NonNullByDefault
25 public final class RootScope extends LexicalScope {
26
27 /**
28 * The scope constructor
29 */
30 public RootScope() {
31 super();
32 }
33
34 @Override
35 @Nullable
36 public ILexicalScope getChild(String name) {
37 /*
38 * This happens ~40 % of the time
39 */
40 if (name.equals(EVENT_HEADER.getPath())) {
41 return EVENT_HEADER;
42 }
43 /*
44 * This happens ~30 % of the time
45 */
46 if (name.equals(FIELDS.getPath())) {
47 return FIELDS;
48 }
49 /*
50 * This happens ~30 % of the time
51 */
52 if (name.equals(CONTEXT.getPath())) {
53 return CONTEXT;
54 }
55 /*
56 * This happens ~1 % of the time
57 */
58 if (name.equals(PACKET_HEADER.getPath())) {
59 return PACKET_HEADER;
60 }
61 return super.getChild(name);
62 }
63
64 }
This page took 0.049026 seconds and 4 git commands to generate.