DrDab / TrcAttendance-Android

An Android port of the TRC Attendance app for FRC meeting attendance logging
http://www.titanrobotics.com/
MIT License
1 stars 0 forks source link

Buggy code #10

Closed trc492 closed 6 years ago

trc492 commented 6 years ago

Don't know what this code is doing but my common sense told me this code doesn't look right. OnActivityResult in MainActivity.java:

    // add new attendants into the list.
    for(int i = 0; i < DataStore.attendanceLog.attendantsList.size(); i++)
    {
        DataStore.allAttendants = new ArrayList<Attendant>();
        Attendant lol = DataStore.attendanceLog.attendantsList.get(i);
        DataStore.allAttendants.add(lol);
        if(DataStore.checkInList.indexOf(lol) == -1)
        {
            DataStore.checkInList.add(lol);
        }
    }

Inside the for-loop, you are creating a new ArrayList overwriting DataStore.allAttendants in every loop. Then you added only ONE element to the array, loop again, created another new ArrayList, added the next ONE element to the new array and repeat …

DrDab commented 6 years ago

Yep, I agree, this isn't very efficient. I will setup something more organized as soon as possible.

DrDab commented 6 years ago

Yep, typo fixed. This should be resolved as of commit c336a60. Don't know what that code was doing in there in the first place, likely an unused code stub for something else.