getLockedCount is iterating over all history of delegations
`getLockedCount` is iterating over all delegations of a specific holder and may even change the state of these delegations by calling `getState`.\\n```\\nfunction getLockedCount(address holder) external returns (uint amount) {\\n    amount = 0;\\n    DelegationController delegationController = DelegationController(contractManager.getContract("DelegationController"));\\n    uint[] memory delegationIds = delegationController.getDelegationsByHolder(holder);\\n    for (uint i = 0; i < delegationIds.length; ++i) {\\n        uint id = delegationIds[i];\\n        if (isLocked(getState(id))) {\\n            amount += delegationController.getDelegation(id).amount;\\n        }\\n    }\\n    return amount + getPurchasedAmount(holder) + this.getSlashedAmount(holder);\\n}\\n```\\n\\nThis problem is major because delegations number is growing over time and may even potentially grow more than the gas limit and lock all tokens forever. `getLockedCount` is called during every transfer which makes any token transfer much more expensive than it should be.
Remove iterations over a potentially unlimited amount of tokens. All the necessary data can be precalculated before and `getLockedCount` function can have O(1) complexity.
```\\nfunction getLockedCount(address holder) external returns (uint amount) {\\n    amount = 0;\\n    DelegationController delegationController = DelegationController(contractManager.getContract("DelegationController"));\\n    uint[] memory delegationIds = delegationController.getDelegationsByHolder(holder);\\n    for (uint i = 0; i < delegationIds.length; ++i) {\\n        uint id = delegationIds[i];\\n        if (isLocked(getState(id))) {\\n            amount += delegationController.getDelegation(id).amount;\\n        }\\n    }\\n    return amount + getPurchasedAmount(holder) + this.getSlashedAmount(holder);\\n}\\n```\\n