Bug 158020 Lazy initialize ViewerComparator.comparator
20060920 In the ViewerSorter I remember that a performance problem was that that the default constructor called Collator.getInstance() which can be expensive for the first caller. So in JDT we overrode getCollator() to do a lazy initialization. Couldn't this be added to the ViewerComparator by default? In ViewerSorter it wasn't possible as collator was protected. In ViewerComparator this isn't a problem. -> public ViewerComparator(){ this(null); } protected Comparator getComparator() { if (comparator == null) comparator= Policy.getComparator(); return comparator; }
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java
this.comparator = comparator;
	}
	/**
	 * Returns the comparator used to sort strings.
	 * 
	 * @return the comparator used to sort strings
	 */
	protected Comparator getComparator() {
		return comparator;
	}
    /**
     * Returns the category of the given element. The category is a
     * number used to allocate elements to bins; the bins are arranged
     * in ascending numeric order. The elements within a bin are arranged
     * via a second level sort criterion.
     * <p>
     * The default implementation of this framework method returns
     * <code>0</code>. Subclasses may reimplement this method to provide
     * non-trivial categorization.
     * </p>
     *
     * @param element the element
     * @return the category
     */
    public int category(Object element) {
        return 0;
    }
    /**
     * Returns a negative, zero, or positive number depending on whether
     * the first element is less than, equal to, or greater than