Ian Hickson 99b991290d Update licenses, and test that licenses are valid (#3286)
* Test that licenses are valid.

* Move license script from flutter/buildroot to flutter/engine
2016-12-02 14:51:39 -08:00

45 lines
1.0 KiB
Dart

// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:collection';
Map<Key, dynamic> _cache = new LinkedHashMap<Key, dynamic>();
const int _maxSize = 10;
dynamic/*=T*/ cache/*<T>*/(Key key, dynamic/*=T*/ getter()) {
dynamic/*=T*/ result = _cache[key];
if (result != null) {
_cache.remove(key);
} else {
if (_cache.length == _maxSize)
_cache.remove(_cache.keys.first);
result = getter();
assert(result is! Function);
}
_cache[key] = result;
return result;
}
abstract class Key {
Key(this._value);
final dynamic _value;
@override
bool operator ==(dynamic other) {
if (identical(this, other))
return true;
if (runtimeType != other.runtimeType)
return false;
final Key typedOther = other;
return _value == typedOther._value;
}
@override
int get hashCode => runtimeType.hashCode ^ _value.hashCode;
@override
String toString() => '$runtimeType($_value)';
}