org.casbin.jcasbin.persist.JDBCBaseAdapter has loadPolicy method to fetch data from db.
Then it iterates over the rows and for each of the row it calls loadPolicyLine -> Helper.loadPolicyLine.
Inside helper there is:
public static void loadPolicyLine(String line, Model model) {
if (!"".equals(line)) {
if (line.charAt(0) != '#') {
String[] tokens = Util.splitCommaDelimited(line);
String key = tokens[0];
String sec = key.substring(0, 1);
Assertion ast = (Assertion)((Map)model.model.get(sec)).get(key);
ast.policy.add(Arrays.asList(Arrays.copyOfRange(tokens, 1, tokens.length)));
for(int i = 0; i < ast.policy.size(); ++i) {
ast.policyIndex.put(((List)ast.policy.get(i)).toString(), i);
}
}
}
}
one more row loop.
so for the db rows it will iterate like this:
1 1 1 ... n
2 2 2
3 3
...
n
why do you need this internal for loop?
it can be changed to:
org.casbin.jcasbin.persist.JDBCBaseAdapter
hasloadPolicy
method to fetch data from db. Then it iterates over the rows and for each of the row it callsloadPolicyLine
->Helper.loadPolicyLine
.Inside helper there is:
one more row loop. so for the db rows it will iterate like this:
why do you need this internal for loop? it can be changed to:
so no loop, faster load. what is the reason of it? Or maybe i missed something?