The source code for that function is at https://github.com/ruby/ruby/blob/a75a8ccd9d2fa46eb68fe21469...
You can check the git blame and all the history. Unsurprisingly the function itself is from the 90s.