mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-06-06 22:29:34 +00:00
#416: M1368105
This commit is contained in:
parent
baaf2ee89c
commit
1efa1540f4
|
@ -160,8 +160,10 @@ JSDependentString::new_(js::ExclusiveContext* cx, JSLinearString* baseArg, size_
|
|||
* entirely, however, due to how ropes are flattened.
|
||||
*/
|
||||
if (baseArg->isDependent()) {
|
||||
start += baseArg->asDependent().baseOffset();
|
||||
baseArg = baseArg->asDependent().base();
|
||||
if (mozilla::Maybe<size_t> offset = baseArg->asDependent().baseOffset()) {
|
||||
start += *offset;
|
||||
baseArg = baseArg->asDependent().base();
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(start + length <= baseArg->length());
|
||||
|
|
|
@ -680,7 +680,9 @@ JSDependentString::dumpRepresentation(FILE* fp, int indent) const
|
|||
dumpRepresentationHeader(fp, indent, "JSDependentString");
|
||||
indent += 2;
|
||||
|
||||
fprintf(fp, "%*soffset: %zu\n", indent, "", baseOffset());
|
||||
if (mozilla::Maybe<size_t> offset = baseOffset())
|
||||
fprintf(fp, "%*soffset: %" PRIuSIZE "\n", indent, "", *offset);
|
||||
|
||||
fprintf(fp, "%*sbase: ", indent, "");
|
||||
base()->dumpRepresentation(fp, indent);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/Range.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
@ -694,16 +695,18 @@ class JSDependentString : public JSLinearString
|
|||
JSDependentString& asDependent() const = delete;
|
||||
|
||||
/* The offset of this string's chars in base->chars(). */
|
||||
size_t baseOffset() const {
|
||||
MOZ_ALWAYS_INLINE mozilla::Maybe<size_t> baseOffset() const {
|
||||
MOZ_ASSERT(JSString::isDependent());
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
if (MOZ_UNLIKELY(base()->isUndepended()))
|
||||
return mozilla::Nothing();
|
||||
size_t offset;
|
||||
if (hasTwoByteChars())
|
||||
offset = twoByteChars(nogc) - base()->twoByteChars(nogc);
|
||||
else
|
||||
offset = latin1Chars(nogc) - base()->latin1Chars(nogc);
|
||||
MOZ_ASSERT(offset < base()->length());
|
||||
return offset;
|
||||
return mozilla::Some(offset);
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue
Block a user