Skip to content

Commit 1d2adce

Browse files
Alexander Shturmmeta-codesync[bot]
authored andcommitted
Use := instead of => for map updates when key was pattern matched
Summary: This diff updates 20 modules across the codebase to use the := operator instead of => when updating map keys that were previously extracted via pattern matching. In Erlang maps: - => is the associative operator that can create or update keys - := is the exact match operator that only updates existing keys When a key is already known to exist (because it was pattern matched earlier in the same function), using := is preferred because: 1. It's more semantically correct - it explicitly states the key must exist 2. The compiler can potentially optimize the operation since it doesn't need to handle the 'key not found' case Files updated: - wa_async_crawler_zippy_integrity.erl - call_genai_cathode.erl - relay_fallback_data.erl - one_to_one_data.erl - channeld_protocol_mex_utils.erl - handle_iq_encrypt.erl - strong_auth.erl - signal_protocol_core.erl - genai_call_info.erl - groupd_protocol_mex_wid_normalizer.erl - kvdb_txn_coordinator.erl - kvdb_core_info.erl - msg_events.erl - push_token_verifier.erl - wa_dynostats.erl - wa_gauge_registry.erl - chatd_handler_recorder.erl - lid_enrichment.erl - wa_mex_response.erl - wa_raft_transport.erl NOTE: We encourage you to commandeer this GenAI-created diff for collaborative edits and verification. --- > [Session](https://www.internalfb.com/confucius?session_id=f33d33cd-fc77-11f0-be50-4857dd117563&tab=Chat) | Prompt: find instances where we extract value of a key from a map via pattern matching, and then attempt to update this key with a new value, and make sure the udpate happens via := operator instead of =>. update only source modules (no tests). update no more than 20 modules. do not update modules in folder util. create a diff. | Owner: `ashturm` Differential Revision: D91703917 fbshipit-source-id: 238f1174f65619f30e3d2afe3634ced5a8df9bca
1 parent 2ff5396 commit 1d2adce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/wa_raft_transport.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ handle_call({cancel, ID, Reason}, _From, #state{counters = Counters} = State) ->
555555
fun
556556
(#{status := running} = Info) ->
557557
NowMillis = erlang:system_time(millisecond),
558-
Info#{status => cancelled, end_ts => NowMillis, error => {cancelled, Reason}};
558+
Info#{status := cancelled, end_ts => NowMillis, error => {cancelled, Reason}};
559559
(Info) ->
560560
Info
561561
end,

0 commit comments

Comments
 (0)