Giter Site home page Giter Site logo

Redundant code about aat HOT 4 CLOSED

rparkins999 avatar rparkins999 commented on June 3, 2024
Redundant code

from aat.

Comments (4)

bailuk avatar bailuk commented on June 3, 2024

The first loop is to update the access time inside the 1. Level cache. (if the tile is already loaded).
The second loop is to load missing tiles.

I've added some comments to clarify: 222a07a

from aat.

rparkins999 avatar rparkins999 commented on June 3, 2024

As my comment says, getHandle() always calls through to cache.get() anyway, so you just update the access time twice. I couldn't find any path through getHandle() that didn't call cache.get() before doing anything else.

from aat.

bailuk avatar bailuk commented on June 3, 2024

The first loop only handles cached tiles. It kind of "reserves" them by setting the access time.

Without this loop it might be possible that, in the second loop, a needed tile gets replaced inside the cache before the call to cache.get(). Because the second loop can put (replace) tiles into the cache.

You are right that cache.get() gets called twice, but that is actually intended here.

from aat.

rparkins999 avatar rparkins999 commented on June 3, 2024

Without this loop it might be possible that, in the second loop, a needed tile gets replaced inside the cache before the call to cache.get()

I don't see any way in which this is possible. The first thing that is done in the second loop is to call getHandle() on an object of class Tile. getHandle() is private, so it must be the version in TileProvider which is called.

The first thing that getHandle() does is to call getTileHandle() on the same object of class Tile which was passed to it. getTileHandle() is also private, so it must be the version in TileProvider which is called.

The first thing that getTileHandle() does is to call cache.get() on the same object of class Tile which was passed to it. So there is no way that anything else can happen before cache.get() is called.

If you're suggesting that another thread can change tilePositions[i].tile to point to a different object of class Tile, in that case there was no point in calling cache.get() in the first loop to set the access time, because you aren't going to access the object of class Tile that you called it on.

from aat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.