def _collect_group_names(s):
    """Returns the list of placeholder names found in the given string.

    Placeholders are of the form `{foo}`.

    Args:
      s: The string that potentially contains placeholders.

    Returns:
      A list of placeholder names found in the string, if any.
    """
    names = []
    length = len(s)
    end_index = 0
    for i in range(length):
        # Don't try to capture a placeholder inside another placeholder.
        if i < end_index:
            continue

        ch = s[i]
        if ch == "{":
            end_index = s.find("}", i + 1)
            if end_index != -1:
                names.append(s[(i + 1):end_index])
    return names