MCPcopy Create free account
hub / github.com/aitjcize/cppman / _commonprefix

Function _commonprefix

cppman/main.py:96–104  ·  view source on GitHub ↗

Given two strings, returns the longest common leading prefix

(s1, s2)

Source from the content-addressed store, hash-verified

94
95# Return the longest prefix of all list elements.
96def _commonprefix(s1, s2):
97 """" Given two strings, returns the longest common leading prefix """
98
99 if len(s1) > len(s2):
100 s1, s2 = s2, s1;
101 for i, c in enumerate(s1):
102 if c != s2[i]:
103 return s1[:i]
104 return s1
105
106def _removeprefix(string, prefix):
107 if prefix and string.startswith(prefix):

Callers 1

process_documentMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected