Mercurial > emacs
comparison src/buffer.c @ 7670:b3be53811505
(verify_overlay_modification): GCPRO tail and overlay.
Avoid copying tail twice.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 24 May 1994 21:16:23 +0000 |
parents | 6cc6328992d6 |
children | f6c309d5d314 |
comparison
equal
deleted
inserted
replaced
7669:93b5868150b9 | 7670:b3be53811505 |
---|---|
2132 verify_overlay_modification (start, end) | 2132 verify_overlay_modification (start, end) |
2133 Lisp_Object start, end; | 2133 Lisp_Object start, end; |
2134 { | 2134 { |
2135 Lisp_Object prop, overlay, tail; | 2135 Lisp_Object prop, overlay, tail; |
2136 int insertion = EQ (start, end); | 2136 int insertion = EQ (start, end); |
2137 | 2137 int tail_copied; |
2138 struct gcpro gcpro1, gcpro2; | |
2139 | |
2140 overlay = Qnil; | |
2141 tail = Qnil; | |
2142 GCPRO2 (overlay, tail); | |
2143 | |
2144 tail_copied = 0; | |
2138 for (tail = current_buffer->overlays_before; | 2145 for (tail = current_buffer->overlays_before; |
2139 CONSP (tail); | 2146 CONSP (tail); |
2140 tail = XCONS (tail)->cdr) | 2147 tail = XCONS (tail)->cdr) |
2141 { | 2148 { |
2142 int startpos, endpos; | 2149 int startpos, endpos; |
2154 { | 2161 { |
2155 prop = Foverlay_get (overlay, Qinsert_in_front_hooks); | 2162 prop = Foverlay_get (overlay, Qinsert_in_front_hooks); |
2156 if (!NILP (prop)) | 2163 if (!NILP (prop)) |
2157 { | 2164 { |
2158 /* Copy TAIL in case the hook recenters the overlay lists. */ | 2165 /* Copy TAIL in case the hook recenters the overlay lists. */ |
2159 tail = Fcopy_sequence (tail); | 2166 if (!tail_copied) |
2167 tail = Fcopy_sequence (tail); | |
2168 tail_copied = 1; | |
2160 call_overlay_mod_hooks (prop, overlay, start, end); | 2169 call_overlay_mod_hooks (prop, overlay, start, end); |
2161 } | 2170 } |
2162 } | 2171 } |
2163 if (XFASTINT (start) == endpos && insertion) | 2172 if (XFASTINT (start) == endpos && insertion) |
2164 { | 2173 { |
2165 prop = Foverlay_get (overlay, Qinsert_behind_hooks); | 2174 prop = Foverlay_get (overlay, Qinsert_behind_hooks); |
2166 if (!NILP (prop)) | 2175 if (!NILP (prop)) |
2167 { | 2176 { |
2168 tail = Fcopy_sequence (tail); | 2177 if (!tail_copied) |
2178 tail = Fcopy_sequence (tail); | |
2179 tail_copied = 1; | |
2169 call_overlay_mod_hooks (prop, overlay, start, end); | 2180 call_overlay_mod_hooks (prop, overlay, start, end); |
2170 } | 2181 } |
2171 } | 2182 } |
2172 /* Test for intersecting intervals. This does the right thing | 2183 /* Test for intersecting intervals. This does the right thing |
2173 for both insertion and deletion. */ | 2184 for both insertion and deletion. */ |
2174 if (XFASTINT (end) > startpos && XFASTINT (start) < endpos) | 2185 if (XFASTINT (end) > startpos && XFASTINT (start) < endpos) |
2175 { | 2186 { |
2176 prop = Foverlay_get (overlay, Qmodification_hooks); | 2187 prop = Foverlay_get (overlay, Qmodification_hooks); |
2177 if (!NILP (prop)) | 2188 if (!NILP (prop)) |
2178 { | 2189 { |
2179 tail = Fcopy_sequence (tail); | 2190 if (!tail_copied) |
2191 tail = Fcopy_sequence (tail); | |
2192 tail_copied = 1; | |
2180 call_overlay_mod_hooks (prop, overlay, start, end); | 2193 call_overlay_mod_hooks (prop, overlay, start, end); |
2181 } | 2194 } |
2182 } | 2195 } |
2183 } | 2196 } |
2184 | 2197 |
2198 tail_copied = 0; | |
2185 for (tail = current_buffer->overlays_after; | 2199 for (tail = current_buffer->overlays_after; |
2186 CONSP (tail); | 2200 CONSP (tail); |
2187 tail = XCONS (tail)->cdr) | 2201 tail = XCONS (tail)->cdr) |
2188 { | 2202 { |
2189 int startpos, endpos; | 2203 int startpos, endpos; |
2200 if (XFASTINT (end) == startpos && insertion) | 2214 if (XFASTINT (end) == startpos && insertion) |
2201 { | 2215 { |
2202 prop = Foverlay_get (overlay, Qinsert_in_front_hooks); | 2216 prop = Foverlay_get (overlay, Qinsert_in_front_hooks); |
2203 if (!NILP (prop)) | 2217 if (!NILP (prop)) |
2204 { | 2218 { |
2205 tail = Fcopy_sequence (tail); | 2219 if (!tail_copied) |
2220 tail = Fcopy_sequence (tail); | |
2221 tail_copied = 1; | |
2206 call_overlay_mod_hooks (prop, overlay, start, end); | 2222 call_overlay_mod_hooks (prop, overlay, start, end); |
2207 } | 2223 } |
2208 } | 2224 } |
2209 if (XFASTINT (start) == endpos && insertion) | 2225 if (XFASTINT (start) == endpos && insertion) |
2210 { | 2226 { |
2211 prop = Foverlay_get (overlay, Qinsert_behind_hooks); | 2227 prop = Foverlay_get (overlay, Qinsert_behind_hooks); |
2212 if (!NILP (prop)) | 2228 if (!NILP (prop)) |
2213 { | 2229 { |
2214 tail = Fcopy_sequence (tail); | 2230 if (!tail_copied) |
2231 tail = Fcopy_sequence (tail); | |
2232 tail_copied = 1; | |
2215 call_overlay_mod_hooks (prop, overlay, start, end); | 2233 call_overlay_mod_hooks (prop, overlay, start, end); |
2216 } | 2234 } |
2217 } | 2235 } |
2218 /* Test for intersecting intervals. This does the right thing | 2236 /* Test for intersecting intervals. This does the right thing |
2219 for both insertion and deletion. */ | 2237 for both insertion and deletion. */ |
2220 if (XFASTINT (end) > startpos && XFASTINT (start) < endpos) | 2238 if (XFASTINT (end) > startpos && XFASTINT (start) < endpos) |
2221 { | 2239 { |
2222 prop = Foverlay_get (overlay, Qmodification_hooks); | 2240 prop = Foverlay_get (overlay, Qmodification_hooks); |
2223 if (!NILP (prop)) | 2241 if (!NILP (prop)) |
2224 { | 2242 { |
2225 tail = Fcopy_sequence (tail); | 2243 if (!tail_copied) |
2244 tail = Fcopy_sequence (tail); | |
2245 tail_copied = 1; | |
2226 call_overlay_mod_hooks (prop, overlay, start, end); | 2246 call_overlay_mod_hooks (prop, overlay, start, end); |
2227 } | 2247 } |
2228 } | 2248 } |
2229 } | 2249 } |
2250 | |
2251 UNGCPRO; | |
2230 } | 2252 } |
2231 | 2253 |
2232 static void | 2254 static void |
2233 call_overlay_mod_hooks (list, overlay, start, end) | 2255 call_overlay_mod_hooks (list, overlay, start, end) |
2234 Lisp_Object list, overlay, start, end; | 2256 Lisp_Object list, overlay, start, end; |