Delta between two modes as a string old.Delta(new). JRPAS -> JRWS: "+W-PA" Zero delta is an empty string ""
(n AccessMode)
| 712 | // Delta between two modes as a string old.Delta(new). JRPAS -> JRWS: "+W-PA" |
| 713 | // Zero delta is an empty string "" |
| 714 | func (o AccessMode) Delta(n AccessMode) string { |
| 715 | // Removed bits, bits present in 'old' but missing in 'new' -> '-' |
| 716 | var removed string |
| 717 | if o2n := ModeBitmask & o &^ n; o2n > 0 { |
| 718 | removed = o2n.String() |
| 719 | if removed != "" { |
| 720 | removed = "-" + removed |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | // Added bits, bits present in 'n' but missing in 'o' -> '+' |
| 725 | var added string |
| 726 | if n2o := ModeBitmask & n &^ o; n2o > 0 { |
| 727 | added = n2o.String() |
| 728 | if added != "" { |
| 729 | added = "+" + added |
| 730 | } |
| 731 | } |
| 732 | return added + removed |
| 733 | } |
| 734 | |
| 735 | // ApplyMutation sets of modifies access mode: |
| 736 | // * if `mutation` contains either '+' or '-', attempts to apply a delta change on `m`. |