<commit_before>package polyglot.util;

import java.io.Serializable;

/**
 * This class represents a posiiton within a file.
 **/
public class Position implements Serializable
{
    static final long serialVersionUID = -4588386982624074261L;

    private String path;
    private String file;
    private int line;
    private int column;
    
    private int endLine;
    private int endColumn;

    public static final int UNKNOWN = -1;
    public static final int END_UNUSED = -2;
    public static final Position COMPILER_GENERATED = new Position(null, "Compiler Generated");
    
    public static final int THIS_METHOD = 1;
    public static final int CALLER = THIS_METHOD + 1;

    /**
     * Get a compiler generated position using the caller at the given stack
     * depth.  Depth 1 is the caller.  Depth 2 is the caller's caller, etc.
     */ 
    public static Position compilerGenerated(int depth) {
        StackTraceElement[] stack = new Exception().getStackTrace();
        if (depth < stack.length) {
            return new Position(null, stack[depth].getFileName() + " (compiler generated)", stack[depth].getLineNumber());
        }
        else {
            return COMPILER_GENERATED;
        }
    }

    /** Get a compiler generated position. */ 
    public static Position compilerGenerated() {
        return compilerGenerated(CALLER);
    }

    /** For deserialization. */
    protected Position() { }

    public Position(String path, String file) {
    this(path, file, UNKNOWN, UNKNOWN);
    }<commit_msg>In method compilerGenerated, check whether -outputamb is set, and don't call getStackTraceElement if so, since it is not going to be used anyway. This seems to be able to improve the performance a lot.<commit_after>package polyglot.util;

import java.io.Serializable;
import polyglot.main.Options;

/**
 * This class represents a posiiton within a file.
 **/
public class Position implements Serializable
{
    static final long serialVersionUID = -4588386982624074261L;

    private String path;
    private String file;
    private int line;
    private int column;
    
    private int endLine;
    private int endColumn;

    public static final int UNKNOWN = -1;
    public static final int END_UNUSED = -2;
    public static final Position COMPILER_GENERATED = new Position(null, "Compiler Generated");
    
    public static final int THIS_METHOD = 1;
    public static final int CALLER = THIS_METHOD + 1;

    /**
     * Get a compiler generated position using the caller at the given stack
     * depth.  Depth 1 is the caller.  Depth 2 is the caller's caller, etc.
     */ 
    public static Position compilerGenerated(int depth) {
    	if (Options.global.output_ambiguous_nodes) return COMPILER_GENERATED;
        StackTraceElement[] stack = new Exception().getStackTrace();
        if (depth < stack.length) {
            return new Position(null, stack[depth].getFileName() + " (compiler generated)", stack[depth].getLineNumber());
        }
        else {
            return COMPILER_GENERATED;
        }
    }

    /** Get a compiler generated position. */ 
    public static Position compilerGenerated() {
        return compilerGenerated(CALLER);
    }

    /** For deserialization. */
    protected Position() { }

    public Position(String path, String file) {
    this(path, file, UNKNOWN, UNKNOWN);
    }
{'fraction_non_alphanumeric': 0.08306043465317059, 'fraction_numerical': 0.014885382554331646, 'mean_word_length': 2.888888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4988516', 'n_tokens_mistral': 939, 'n_tokens_neox': 872, 'n_words': 329}