Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#19354 closed enhancement (fixed)

UndoRedoHandler.getUndoCommands: return unmodifiable list

Reported by: simon04 Owned by: team
Priority: normal Milestone: 20.06
Component: Core Version:
Keywords: refactoring Cc: taylor.smock

Description

Avoids unnecessary list creation.

  • src/org/openstreetmap/josm/data/UndoRedoHandler.java

    diff --git a/src/org/openstreetmap/josm/data/UndoRedoHandler.java b/src/org/openstreetmap/josm/data/UndoRedoHandler.java
    index 239693b43..c930656a7 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data;
    33
     4import java.util.Collections;
    45import java.util.EventObject;
    56import java.util.LinkedList;
    67import java.util.List;
    void fire(CommandQueuePreciseListener listener) {  
    239240     * @return all commands that were made on the dataset, that can be undone
    240241     * @since 14281
    241242     */
    242     public LinkedList<Command> getUndoCommands() {
    243         return new LinkedList<>(commands);
     243    public List<Command> getUndoCommands() {
     244        return Collections.unmodifiableList(commands);
    244245    }
    245246
    246247    /**
    void fire(CommandQueuePreciseListener listener) {  
    248249     * @return all commands that were made and undone on the dataset, that can be redone.
    249250     * @since 14281
    250251     */
    251     public LinkedList<Command> getRedoCommands() {
    252         return new LinkedList<>(redoCommands);
     252    public List<Command> getRedoCommands() {
     253        return Collections.unmodifiableList(redoCommands);
    253254    }
    254255
    255256    /**

Requires recompilation of some plugins:

Attachments (0)

Change History (9)

comment:1 by simon04, 4 years ago

Resolution: fixed
Status: newclosed

In 16567/josm:

fix #19354 - UndoRedoHandler.getUndoCommands: return unmodifiable list

comment:2 by simon04, 4 years ago

In 16568/josm:

see #19354 - UndoRedoHandler: make commands, redoCommands private

comment:3 by simon04, 4 years ago

Cc: taylor.smock added

comment:4 by simon04, 4 years ago

reverter and utilsplugin2 updated in [o35487:35488]

comment:5 by simon04, 4 years ago

In 16569/josm:

see #19354 - Fix compile error

comment:6 by GerdP, 4 years ago

See also #17196. Do you plan more changes in UndoRedoHandler?

comment:7 by taylor.smock, 4 years ago

MapWithAI has been updated in v1.6.0. It just has to run through the release process now. :)

comment:8 by simon04, 4 years ago

In 16577/josm:

see #19354 - Fix FixDataHookTest

comment:9 by simon04, 4 years ago

Relates to #16745.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.