From 6cc82dda331b5f6eafa498ea69a177cce02d707c Mon Sep 17 00:00:00 2001 From: ThomasBreuer Date: Mon, 16 Sep 2024 14:25:18 +0200 Subject: [PATCH] address comments --- src/julia_to_gap.jl | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/julia_to_gap.jl b/src/julia_to_gap.jl index 35d6b910e..219b46ee0 100644 --- a/src/julia_to_gap.jl +++ b/src/julia_to_gap.jl @@ -85,27 +85,19 @@ function GapObj_internal end # to a GAP record. # Thus we have a default method returning `true`. # -# Methods for those types that want `false` have to be installed; -# the `GapObj` methods arising from `GAP.@install` calls are unary, -# therefore the macro automatically installs such a -# `_needs_tracking_julia_to_gap` method. +# Methods for those types that want `false` have to be installed explicitly. +# The `GapObj` methods arising from `GAP.@install` don't handle recursion +# and the macro automatically installs such a `_needs_tracking_julia_to_gap` +# method. _needs_tracking_julia_to_gap(::Any) = true GAP.@install GapObj(x::FFE) = x # Default for actual GAP objects is to do nothing GAP.@install GapObj(x::Bool) = x # Default for actual GAP objects is to do nothing -## Integers: general case first deal with things that fit into immediate -## integers, then falls back to converting to BigInt and calling into the GAP -## kernel API. -## TODO: we could provide more efficient conversion for UInt64, Int128, UInt128 -## which avoids the conversion to BigInt, if we wanted to. -function GapObj_internal(x::Integer, cache::GapCacheDict, ::Val{recursive}) where recursive - # if it fits into a GAP immediate integer, convert x to Int64 - x in -1<<60:(1<<60-1) && return Int64(x) - # for the general case, fall back to BigInt - return GapObj_internal(BigInt(x), cache, Val(recursive)) -end +## Integers: +## We do not want to track conversion for any concrete integer types. +@install GapObj(x::Integer) = x in -1<<60:(1<<60-1) ? Int64(x) : GapObj(BigInt(x)) ## Small integers types always fit into GAP immediate integers, and thus are ## represented by Int64 on the Julia side.