Closed Bug 88623 Opened 24 years ago Closed 23 years ago

Cleanup Transformiix code

Categories

(Core :: XSLT, defect, P4)

defect

Tracking

()

VERIFIED FIXED
mozilla1.1beta

People

(Reporter: peterv, Assigned: peterv)

References

Details

Attachments

(2 files, 21 obsolete files)

68.39 KB, patch
sicking
: review+
Details | Diff | Splinter Review
66.98 KB, patch
Details | Diff | Splinter Review
First up, some warning fixes. See also bug 88612 for XPath code clean-up.
Status: NEW → ASSIGNED
Priority: -- → P4
Target Milestone: --- → mozilla1.0
Attached patch Warning fixes (obsolete) — Splinter Review
Attached patch Warning fixes v2 (obsolete) — Splinter Review
sr=jst
First patch checked in.
Attached patch Comment clean-up (obsolete) — Splinter Review
Comments like * $Id: AdditiveExpr.cpp,v 1.1 2000/04/06 07:44:37 kvisco%ziplink.net Exp $ * @author <A HREF="mailto:kvisco@ziplink.net">Keith Visco</A> * @version $Revision: 1.1 $ $Date: 2000/04/06 07:44:37 $ ought to go, giving a rs to peterv for removing those Axel
de-rubberfying. r=me on attachement 40874 Axel
rs=jst
r=sicking on attachment 52145 [details] [diff] [review] However, I just noticed a pretty serious thing in txResultStringComparator::compareValues which would be nice if you could fix while you're at it. If createRawSortKey fails when creating mCaseKey/mCaseLength the StringValue ends up in a pretty bad state; mCaseKey gets set to null making us leak the String* key and mCaseLength is set to >0 indicating that mCaseKey points to the mCollation-key. Would be great if you could do something about that
Good catch. How about restoring the string pointer in mCaseKey and setting mCaseLength to 0? I'm attaching another patch. It's not cleanup in the strict sense of the word, it adds String::isEmpty(). I've tried replacing all the length==0, >0, !=0 in the tree where it made sense. I've avoided doing cleanup or restructuring, except in some extreme cases. Looking for an r on that one too.
Attached patch Adding String::isEmpty() (obsolete) — Splinter Review
Attachment #40783 - Attachment is obsolete: true
Attachment #40787 - Attachment is obsolete: true
Attachment #40874 - Attachment is obsolete: true
yes, restoring mCaseKey and mCaseLength seems like the safest thing (though not neccesarily the fastest when it comes to what happens if we fail, but i don't see any reason to optimize that anyway)
on attachment 52208 [details] [diff] [review]: +MBool String::isEmpty() const +{ + return (!strBuffer || (strBuffer[0] == 0x0000)); +} won't work (our strings arn't always nullterminated, see implementation of ::clear), just do |return strLength == 0| urgl, horrible indentation in + case 0x000D: // CR + break; + default: + toStrip = MB_FALSE; + break; please add another level for the actual codelines I don't like the changes to StringFunctionCall.cpp, why add an optimization (which indents the code one extra level) for a case that is very unlikly to happen? in ProcessorState::getResultNameSpaceURI: - if (prefix.length() == 0) { + if (!prefix.isEmpty()) { is wrong appart from that and assuming the changes in ProcessorState::initialize are whitespace only, r=sicking
above patch removes NamedMap::equals which gives Nisheeth 14(!) warnings. The function isn't implemented and isn't used anywere. There is no risk for fallbacks to TxObject::equals since NamedMap::equals has a different signature
Comment on attachment 53310 [details] [diff] [review] remove NamedMap::Equals r=axel@pike.org
Attachment #53310 - Flags: review+
Attachment #52145 - Attachment is obsolete: true
Attachment #52208 - Attachment is obsolete: true
Attachment #53310 - Attachment is obsolete: true
Attached patch Combining previous patches (obsolete) — Splinter Review
Comment on attachment 53670 [details] [diff] [review] Combining previous patches r=sicking
Attachment #53670 - Flags: review+
Comment on attachment 53670 [details] [diff] [review] Combining previous patches oh, another r=me. no landing order requests, that patch merges with nsdoom, so I'm all fine
Comment on attachment 53670 [details] [diff] [review] Combining previous patches sr=jst
Attachment #53670 - Flags: superreview+
Comment on attachment 53670 [details] [diff] [review] Combining previous patches Checked in.
Attachment #53670 - Attachment is obsolete: true
Attached patch And more (obsolete) — Splinter Review
Comment on attachment 53736 [details] [diff] [review] And more nice. less warnings is always a good thing.
Attachment #53736 - Flags: review+
Comment on attachment 53736 [details] [diff] [review] And more another one bites the dust.
Attachment #53736 - Attachment is obsolete: true
*** Bug 59853 has been marked as a duplicate of this bug. ***
The attached patch cleans up some uses of txListIterator. Most of the fixes are changing |ListIterator iter = foo.iterator()| to |txListIterator iter(&foo)|. Since I touched almost all instantiations of ListIterators I took the opportunity to remove the "ListIterator" typedef (actually i'd like to name it txList::iterator instead of txListIterator, thoughts?). To do the same for stackiterators I had to create an explicit txStackIterator class (since Stack can't be cast to txList since Stack inherits txList privately). There are other solutions to this, but I like this one best since it makes it impossible to make an iterator that adds/deletes elements elements down in the stack.
Bugs targeted at mozilla1.0 without the mozilla1.0 keyword moved to mozilla1.0.1 (you can query for this string to delete spam or retrieve the list of bugs I've moved)
Target Milestone: mozilla1.0 → mozilla1.0.1
I've removed ArrayList, only Node on standalone uses it and I've made a small, simple replacement class. Also removed TxObjectWrapper, I know Axel does this on his branch but doing it separately shouldn't give merge problems, right? I've also moved URIUtils to base, we don't need a separate source directory for two files.
Target Milestone: mozilla1.0.1 → mozilla1.1alpha
New patches coming up.
Target Milestone: mozilla1.1alpha → mozilla1.1beta
Attachment #85109 - Attachment is obsolete: true
Attached patch remove XSLType (obsolete) — Splinter Review
Comment on attachment 87054 [details] [diff] [review] remove ArrayList/TxObjectWrapper, move URIUtils to base I don't understand how the new string-list works. Where are the actual strings allocated? I can only find allocation of stringpointers. Couldn't you use a txList instead? The only dissadvantage of that is that you'll have to manually deallocate the strings, but that is IMHO not a big problem.
baseUrls.add(new String(((Document*)node)->getBaseURI())); and +String* txBaseURLArray::getCurrent() +{ + if (mCurrentURL) { + mCurrentURL = new String; + }
Oh, and make that if (!mCurrentURL).
on attachment 87057 [details] [diff] [review]: + // xsl:param + else if (localName == txXSLTAtoms::param) { String name; element->getAttr(txXSLTAtoms::name, kNameSpaceID_None, name); if (name.isEmpty()) { String err("missing required name attribute for... aPs->receiveError(err, NS_ERROR_FAILURE); - break; } - - ExprResult* exprResult - = processVariable(aSource, element, aPs); + else { + ExprResult* exprResult = processVariable(aSource, element... I don't really like putting the non-error code inside an |else|, mind changing the |break| to a |return| instead? ugh, it's such a pity that we don't have nsCOMPtrs in standalone :(.. I wonder if it would be possible to hack one that only handled atoms. (in a separate bug of course) It might be a good idea to have a |XSLTProcessor::isXSLTElementOfType(Node* aNode, txAtom* aType)| function for when/choose/sort/with-param/etc. Your call. - String err("error processing xsl:"); - err.append(PROC_INST); + String err("error processing xsl:processing-instruction"); err.append(", '"); merge the ", '" into the live above @@ -2317,7 +2276,7 @@ XSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM, nsIDOMNode* aStyleDOM, nsIDOMDocument* aOutputDoc, - nsIObserver* aObserver) + nsITransformObserver* aObserver) { // We need source and result documents but no stylesheet. NS_ENSURE_ARG(aSourceDOM); @@ -2495,14 +2454,6 @@ mScriptLoader = nsnull; } - nsresult rv; - nsCOMPtr<nsIObserverService> anObserverService = do_GetService ("@mozilla.org/observer-service;1", &rv); - if (NS_SUCCEEDED(rv)) { - nsCOMPtr<nsIContent> rootContent; - mOutputHandler->getRootContent(getter_AddRefs(rootContent)); - anObserverService->AddObserver(mObserver, "xslt-done", PR_TRUE); - anObserverService->NotifyObservers(rootContent, "xslt-done", nsnull); - } is this supposed to be part of this patch? other then that, r=sicking
Attached patch remove XSLType (obsolete) — Splinter Review
Adressed comments.
Attachment #87056 - Attachment is obsolete: true
Attachment #87057 - Attachment is obsolete: true
Comment on attachment 87456 [details] [diff] [review] remove XSLType (diff -w for reviewers) sr=jst
Attachment #87456 - Flags: superreview+
Comment on attachment 87454 [details] [diff] [review] remove XSLType Checked in.
Attachment #87454 - Attachment is obsolete: true
Attachment #87456 - Attachment is obsolete: true
I didn't use StringList because I think it's overkill for this simple use.
Attachment #87054 - Attachment is obsolete: true
+ ~txBaseURLArray() + { + delete [] mURLs; + } Wasn't the whole point of this class to delete the strings in the dtor so that you wouldn't have to do that manually? + String* get(PRUint32 aCount) + { + if (!mURLs) { + return 0; + } + return mURLs[aCount]; + } IMHO the |if (!mURLs) {| isn't really needed. mCount will always be 0 if mURLs is null, so all indexes to |get| will be illegal anyway. + memcpy(temp, mURLs, mCount * sizeof(String*)); + delete mURLs; + mURLs = temp; + mMax = newMax; should be |delete [] mURLs| i think + if (!current) { + current = new String; + } |current| is always null here, right? Couldn't current just be a local variable in the |case Node::ELEMENT_NODE|? + case Node::DOCUMENT_NODE: + { baseUrls.add(new String(((Document*)node)->getBaseURI())); break; you added an out-of-memory check for the |new| for elements, it'd be great if you did the same for documents. + PRUint32 i; + for (i = baseUrls.mCount - 2; i >= 0; --i) { |i| being unsigned is a bad thing :-)
Now that we don't use ProcessorStates for standalone XPath we no longer need the "empty" ctor for ProcessorState
brought this one back to life again
Attachment #55414 - Attachment is obsolete: true
it's always a good idea to let cvs finish before attaching...
txBaseURLArray::get should check for aCount<mMax, at least in a assertion. Then you can drop the check for mUrls, too.
> Wasn't the whole point of this class to delete the strings in the dtor so that > you wouldn't have to do that manually? Nope. The point to doing it this way is to loop once. > |current| is always null here, right? Couldn't current just be a local > variable in the |case Node::ELEMENT_NODE|? Nope. Only in the first iteration or if the element from the previous iteration has a base attribute. > txBaseURLArray::get should check for aCount<mMax, at least in a assertion. Only in an assertion. This class isn't meant to be used elsewhere, so we're sure the indexes will be correct. I meant to remove the check for mURLs but I forgot.
Comment on attachment 87870 [details] [diff] [review] remove default ctor in ProcessorState r=peterv. Should we assert about the documents?
Attachment #87870 - Flags: review+
Attachment #87873 - Attachment is obsolete: true
same as before and asserts that all documents are supplied
Attachment #87870 - Attachment is obsolete: true
Comment on attachment 87958 [details] [diff] [review] remove default ctor in ProcessorState and assert documents carry forward r=
Attachment #87958 - Flags: review+
Comment on attachment 87958 [details] [diff] [review] remove default ctor in ProcessorState and assert documents sr=jst
Attachment #87958 - Flags: superreview+
Comment on attachment 87958 [details] [diff] [review] remove default ctor in ProcessorState and assert documents this didn't land yet, right?
Comment on attachment 87958 [details] [diff] [review] remove default ctor in ProcessorState and assert documents Now it has :-)
Attachment #87958 - Attachment is obsolete: true
Comment on attachment 87876 [details] [diff] [review] remove txList::iterator() (sync with tip) r=peterv
Attachment #87876 - Flags: review+
Comment on attachment 88799 [details] [diff] [review] remove ArrayList/TxObjectWrapper, move URIUtils to base if we'd resolve baseURI from child to parent, the txBaseURIArray could be dropped. Logic should be pretty simple, resolve as usual and stop on first absolute URI. The rest looks good to me. (It's a toughy after all ;-))
Something like this. Maybe I should try it out ;-). Let's sleep first.
Attachment #88799 - Attachment is obsolete: true
Note: I probably inversed the base and the relative URI.
resolving from child and up won't work for module at least (not sure what standalones url-resolver can handle). When the uri-resolver in mozilla always operates by resolving a relative uri against an absolute one, so you always need to start out with a absolute one.
Comment on attachment 88799 [details] [diff] [review] remove ArrayList/TxObjectWrapper, move URIUtils to base >+void txBaseURLArray::add(String* aURL) >+{ >+ if (mCount == mMax) { >+ PRUint32 newMax = mCount + 16; >+ String** temp = new String*[newMax]; >+ if (!temp) { >+ return; >+ } >+ memcpy(temp, mURLs, mCount * sizeof(String*)); >+ delete mURLs; delete [] mURLs other then that, r=sicking
Attachment #88799 - Attachment is obsolete: false
Attachment #88799 - Flags: review+
Comment on attachment 87876 [details] [diff] [review] remove txList::iterator() (sync with tip) sr=jst
Attachment #87876 - Flags: superreview+
Comment on attachment 89014 [details] [diff] [review] remove ArrayList/TxObjectWrapper, move URIUtils to base Re #63, we don't do the resolving at all for module, we use nsIDOM3Node::GetBaseURI. And for standalone, the document doesn't have a absolute URL, too. Unobsoleting again, but I still have to take a real look at the patch.
Attachment #89014 - Attachment is obsolete: false
Ok, this is getting too complicated for my small mind. Let's land the piece we all agree on.
Comment on attachment 89065 [details] [diff] [review] remove TxObjectWrapper, move URIUtils to base Didn't try to build it, and can´t really do that right now. Assuming that you checked this on the tier 1s, r=axel@pike.org
Attachment #89065 - Flags: review+
spawned bug 154172 for baseURI (and ArrayList, too?), as that thing is just broken for standalone.
Comment on attachment 89065 [details] [diff] [review] remove TxObjectWrapper, move URIUtils to base sr=jst
Attachment #89065 - Flags: superreview+
Comment on attachment 89065 [details] [diff] [review] remove TxObjectWrapper, move URIUtils to base Checked in
Attachment #89065 - Attachment is obsolete: true
Comment on attachment 87876 [details] [diff] [review] remove txList::iterator() (sync with tip) checked in
Attachment #87876 - Attachment is obsolete: true
ok, this one has become pretty long so let's close it off and open a new one if needed
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Alias: cleanup_transformiix → cleanup_tx_old
we didn't verify for a long time. I really checked, so VERIFIED.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: