Modify

Opened 5 weeks ago

Closed 5 weeks ago

Last modified 3 weeks 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 Changed 5 weeks ago by simon04

Resolution: fixed
Status: newclosed

In 16567/josm:

fix #19354 - UndoRedoHandler.getUndoCommands: return unmodifiable list

comment:2 Changed 5 weeks ago by simon04

In 16568/josm:

see #19354 - UndoRedoHandler: make commands, redoCommands private

comment:3 Changed 5 weeks ago by simon04

Cc: taylor.smock added

comment:4 Changed 5 weeks ago by simon04

reverter and utilsplugin2 updated in [o35487:35488]

comment:5 Changed 5 weeks ago by simon04

In 16569/josm:

see #19354 - Fix compile error

comment:6 Changed 5 weeks ago by GerdP

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

comment:7 Changed 5 weeks ago by taylor.smock

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

comment:8 Changed 5 weeks ago by simon04

In 16577/josm:

see #19354 - Fix FixDataHookTest

comment:9 Changed 3 weeks ago by simon04

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.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.