| Summary: | Optimization for containment proxies. | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Simon Mc Duff <smcduff> | ||||
| Component: | Core | Assignee: | Ed Merks <Ed.Merks> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | enhancement | ||||||
| Priority: | P3 | CC: | Ed.Merks | ||||
| Version: | 2.4.0 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Simon Mc Duff
Created attachment 111969 [details]
Further optimizations of contains testing for containment lists
The idea here is that I resolve the container if it's a proxy. If the regular test as before doesn't yield true, then we do additional checking only if we're resolving proxies, the container is null (if it's in a different non-null container then it can't be contained in the list) and if the object is directly in a resource (if it isn't in a resource, a proxy can't resolve to it, so no point in checking the proxies). And if the container itself is an unresolved proxy, it hard to imagine that the proxies in the "real container" could resolve themselves to the object. I think this change is especially nice because it allows new detached objects to be added to a containment list, even a proxy resolving one, without an O(n) test.
I've not tested it very well beyond the normal tests, which do include cross resource containment tests, but it's early in the release cycle so there will be plenty of time to detect any major mistakes in my though processes...
Does this look good to you?
Question: Why in one you used "owner" and the other you used "eContainer" ? if (hasProxies() && !result && >>owner<< == null && eObject.eDirectResource) and yes it will solve my problem. when result == false and the eContainer != null... it will not test it again through the list !! :-) This will improve our code a lot. Thank you Because I didn't test it and I'm not good at copying code. Laziness and stupidity in other words. :-P The changes have been committed to CVS for 2.5. (In reply to comment #4) > The changes have been committed to CVS for 2.5. Thank you Ed, Do you know when 2.5 will be released ? Can we put that change to 2.4 as well ? Simon Releases happen each year at the end of June. I need to be very careful what kinds of changes happen in a maintenance stream. The fact that we're resolving the container reference could potentially have an adverse impact on some application that's not currently expecting this. I don't generally like to take risks with the maintenance stream... Can we add the same technics for Resource.getCOntents ?
Right now we are doing the following:
public boolean contains(Object object)
{
if (useEquals() && object != null)
{
for (int i = 0; i < size; ++i)
{
if (object.equals(data[i]))
{
return true;
}
}
}
else
{
for (int i = 0; i < size; ++i)
{
if (data[i] == object)
{
return true;
}
}
}
return false;
}
We could do the following:
boolean contains(object)
return object.eDirectResource() == resource;
Simon, That's an excellent idea. Please open a bugzilla for that. I imagine we could do a similar thing for ResourceSet.getResources given that Resource.getResourceSet is the inverse. Fix available in HEAD: 2.5.0.I200809161800. Fix available in HEAD: 2.5.0 (R200906151043). |