def perform_substitution(match, substitution_map):
  """Substitutes C++ identifiers with C# identifiers.

  We want to perform subsitutions on function names, but not accidentally hit
  anything else in the string. For example, if the line looks like this:

  /// Returns true if `firebase::crash::Initialize()` has been called.

  Then we want the final string to be:

  /// Returns true if `Firebase.Crash.Initialize()` has been called.

  The regex looks for identifiers enclosed within backticks ignoring things
  like parentheses. If we did the substitution directly, the backticks and
  parentheses would be lost. Instead, what we do is find out what the captured
  match was (in this case, 'firebase::crash::Initialize') then take the whole
  match ('`firebase::crash::Initialize()`'), and subtitute just the portion we
  care about so that the surrounding characters can be preserved.

  Args:
    match: The re.Match object representing the match.
    substitution_map: The dict of potential substitutions.

  Returns:
    The new C# code resulting from performing the substitutions.
  """
  full_match = match.group(0)
  cpp = match.group(1)
  cs = substitution_map.get(cpp)
  if cs:
    return full_match.replace(cpp, cs)
  else:
    return full_match