• Abseil Team's avatar
    Googletest export · 167c5e81
    Abseil Team authored
    Fix Theta(N^2) memory usage of EXPECT_EQ(string) when the strings don't match.
    
    The underlying CalculateOptimalEdits() implementation used a simple
    dynamic-programming approach that always used N^2 memory and time. This meant
    that tests for equality of large strings were ticking time bombs: They'd work
    fine as long as the test passed, but as soon as the strings differed the test
    would OOM, which is very hard to debug.
    I switched it out for a Dijkstra search, which is still worst-case O(N^2), but
    in the usual case of mostly-matching strings, it is much closer to linear.
    
    PiperOrigin-RevId: 210405025
    167c5e81
gtest.cc 205 KB