 
   defp do_map({key, value, iter}, fun) do
     new_value = fun.({key, value})
-    [{key, new_value} | do_map(next(iter), fun)]
-  end
-
-  # Inlined version of `:maps.iterator/1`
-  @compile {:inline, iterator: 1}
-  defp iterator(map) when is_map(map), do: [0 | map]
-
-  # Inlined version of `:maps.next/1`
-  @compile {:inline, next: 1}
-  defp next({key, val, iter}), do: {key, val, iter}
-
-  defp next([path | map]),
-    do: :erts_internal.map_next(path, map, :iterator)
-
-  defp next(:none), do: :none
+    [{key, new_value} | do_map(:maps.next(iter), fun)]
+  end
 end

  @doc since: "1.13.0"
  @spec map(map, ({key, value} -> value)) :: map
  def map(map, fun) when is_map(map) and is_function(fun, 1) do
    iter = iterator(map)
    next = next(iter)
    :maps.from_list(do_map(next, fun))
  end


  @doc since: "1.13.0"
  @spec filter(map, ({key, value} -> as_boolean(term))) :: map
  def filter(map, fun) when is_map(map) and is_function(fun, 1) do
    iter = :maps.iterator(map)
    next = :maps.next(iter)
    :maps.from_list(do_filter(next, fun))
  end

