1 | // returns number of changes |
2 | static int cset_compareByStruct(Concept c, O... values) ctex {
|
3 | int changes = 0; |
4 | values = expandParams(c.getClass(), values); |
5 | warnIfOddCount(values); |
6 | for (int i = 0; i+1 < l(values); i += 2) {
|
7 | S field = (S) values[i]; |
8 | O value = values[i+1]; |
9 | Field f = setOpt_findField(c.getClass(), field); |
10 | //print("cset: " + c.id + " " + field + " " + struct(value) + " " + f);
|
11 | if (value instanceof RC) value = c._concepts.getConcept((RC) value); |
12 | value = deref(value); |
13 | |
14 | if (value instanceof S && l((S) value) >= concepts_internStringsLongerThan) value = intern((S) value); |
15 | |
16 | if (f == null) {
|
17 | // TODO: keep ref if it exists |
18 | mapPut2(c.fieldValues, field, value instanceof Concept ? c.new Ref((Concept) value) : value); |
19 | c.change(); |
20 | } else if (isSubtypeOf(f.getType(), Concept.Ref.class)) {
|
21 | ((Concept.Ref) f.get(c)).set((Concept) derefRef(value)); |
22 | c.change(); ++changes; |
23 | } else {
|
24 | O old = f.get(c); |
25 | if (!structEq(value, old)) {
|
26 | f.set(c, value); |
27 | if ((f.getModifiers() & java.lang.reflect.Modifier.TRANSIENT) == 0) c.change(); |
28 | ++changes; |
29 | } |
30 | } |
31 | } |
32 | ret changes; |
33 | } |
Began life as a copy of #1009257
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1011826 |
| Snippet name: | cset_compareByStruct - cset with structEq() instead of eq() |
| Eternal ID of this version: | #1011826/2 |
| Text MD5: | 3ed8d5e33327a8263ac52a3b24d47c26 |
| Author: | stefan |
| Category: | javax / concepts |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-11-06 01:02:05 |
| Source code size: | 1231 bytes / 33 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 604 / 641 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |