def add_string(strings, s):
    """Adds a string to the pool, deduping it.  Returns the index of the
    entry of the string, whether new or existing."""
    for n, t in enumerate(strings):
        if t == s:
            return n
    strings.append(s)
    return len(strings) - 1