protected GpioProviderPinCache getPinCache(Pin pin) { int address = pin.getAddress(); // dynamically resize pin cache storage if needed based on pin address if(address > cache.length){ // create a new array with existing contents // that is 100 elements larger than the requested address // (we add the extra 100 elements to provide additional overhead capacity in // an attempt to minimize further array expansion) cache = Arrays.copyOf(cache, address + 100); } // get the cached pin object from the cache GpioProviderPinCache pc = cache[address]; // if no pin object is found in the cache, then we need to create one at this address index in the cache array if(pc == null){ pc = cache[pin.getAddress()] = new GpioProviderPinCache(pin); } return pc; }
protected GpioProviderPinCache getPinCache(Pin pin) { int address = pin.getAddress(); // dynamically resize pin cache storage if needed based on pin address if(address > cache.length){ // create a new array with existing contents // that is 100 elements larger than the requested address // (we add the extra 100 elements to provide additional overhead capacity in // an attempt to minimize further array expansion) cache = Arrays.copyOf(cache, address + 100); } // get the cached pin object from the cache GpioProviderPinCache pc = cache[address]; // if no pin object is found in the cache, then we need to create one at this address index in the cache array if(pc == null){ pc = cache[pin.getAddress()] = new GpioProviderPinCache(pin); } return pc; }