@@ -583,20 +583,6 @@ def _maybe_copy(self, using_cow: bool, inplace: bool) -> Self:
583583 blk = self if inplace else self .copy ()
584584 return blk
585585
586- @final
587- def _get_values_and_refs (self , using_cow , inplace ):
588- if using_cow :
589- if inplace and not self .refs .has_reference ():
590- refs = self .refs
591- new_values = self .values
592- else :
593- refs = None
594- new_values = self .values .copy ()
595- else :
596- refs = None
597- new_values = self .values if inplace else self .values .copy ()
598- return new_values , refs
599-
600586 @final
601587 def _get_refs_and_copy (self , using_cow : bool , inplace : bool ):
602588 refs = None
@@ -738,11 +724,10 @@ def _replace_regex(
738724
739725 rx = re .compile (to_replace )
740726
741- new_values , refs = self ._get_values_and_refs (using_cow , inplace )
727+ block = self ._maybe_copy (using_cow , inplace )
742728
743- replace_regex (new_values , rx , value , mask )
729+ replace_regex (block . values , rx , value , mask )
744730
745- block = self .make_block (new_values , refs = refs )
746731 return block .convert (copy = False , using_cow = using_cow )
747732
748733 @final
0 commit comments